E.V.E
v2023.02.15

◆ geommean

eve::geommean = {}
inlineconstexpr

Callable object computing the geometric mean of the inputs. \( \left(\prod_{i = 1}^n x_i\right)^{1/n} \).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template<fvalue T, value ... Ts>
auto geommean( T x, Ts ... args ) const noexcept
}
Definition: value.hpp:31
constexpr callable_geommean_ geommean
Callable object computing the geometric mean of the inputs. .
Definition: geommean.hpp:67
Definition: abi.hpp:18

Parameters

`x, ... args: floating real or complex values

Return value

  • The geometric mean of the inputs is returned
  • The result type is the common value type of the parameters.

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <vector>
#include <iostream>
int main()
{
w_t pi = {3, 2, 3, -3}, qi = {4, 2, 1, -100};
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> geommean(pi, qi) = " << eve::geommean(pi, qi) << '\n';
float xi = 3, yi = 4;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> geommean(xi, yi) = " << eve::geommean(xi, yi) << '\n';
w_t pf = {3, 1, -3, -10}, qf = {4, 1, 1, 15};;
std::cout << "---- multi" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> geommean(1.0f, qf, pf, 32.0f) = " << eve::geommean(1.0f, qf, pf, 32.0f) << '\n'
<< " -> geommean(1.0f, qf, pf, 32.0f) = " << eve::geommean(1.0f, qf, pf, 32.0f) << '\n'
<< " -> geommean(-1.0f, qf, pf) = " << eve::geommean(-1.0f, qf, pf) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::geommean[mask](x, ...) provides a masked version of eve::geommean which is equivalent to if_else (mask, geommean(x, ...), x).

    Example

    #include <eve/module/math.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {0.0f, -0.0f, -1.0f, 1.0f},
    qf = { 20.0f, -5.0f, 8.0f, 1.0f},
    rf = { 2.0f, 3.0f, 4.0f, 5.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "-> geommean[pf > 1.0](pf, qf, rf) = " << eve::geommean[pf > 1.0](pf, qf, rf) << '\n';
    return 0;
    }