Option 3: define using fully qualified function name
| 46 | |
| 47 | // Option 3: define using fully qualified function name |
| 48 | double math::averages::rms(std::span<const double> data) |
| 49 | { |
| 50 | // The RMS or root mean square is defined as |
| 51 | // square root of the arithmetic mean of the squares of the elements. |
| 52 | double sum_squares{}; |
| 53 | for (auto value : data) |
| 54 | sum_squares += square(value); |
| 55 | |
| 56 | return data.empty() |
| 57 | ? std::numeric_limits<double>::quiet_NaN() // Or std::nan("") |
| 58 | : std::sqrt(sum_squares / data.size()); |
| 59 | } |
| 60 | |
| 61 | // Option 4: define using qualified name in outer namespace block |
| 62 | namespace math |