E.V.E  0.1-beta

◆ geommean

eve::geommean = {}
inlineconstexpr

Callable object computing the mid-point operation.


Parameters

x, y or x, args ...: floating values.

Return value

For two parameters \(\sqrt{xy}\). No overflow occurs.

For more than two parameters \(\sqrt[n]{x_1x_2...x_n}\)

The result type is the common compatible type of the parameters.

Warning
for floating_real_value input types
  • if the number of parameters is even and the product of the parameters is srictly negative the result is a Nan.
  • if the number of parameters is odd the result has the sign of the product of the parameters

auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::geommean

Parameters

cond : conditional expression

Return value

A Callable object so that the expression geommean[cond](x, ...) is equivalent to if_else(cond,geommean(x, ...),x)


Supported decorators

  • diff_nth

    Required header: #include <eve/function/diff/geommean.hpp>

    The expression diff_nth< N >(geommean)(x,args...) computes the partial derivative of the function relative to its Nth parameter. The returned value is 0 if N is greater that the actual number of parameters, otherwise it is similar to geommean(x1,x2,...,xn)/(n*xN).

Example

See it live on Compiler Explorer

#include <eve/function/geommean.hpp>
#include <eve/literals.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_geommean_ geommean
Callable object computing the mid-point operation.
Definition: geommean.hpp:90
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
Wrapper for SIMD registers.
Definition: wide.hpp:65


Required header: #include <eve/function/geommean.hpp>

Members Functions

Member Effect
operator() the mid-point operation
operator[] Construct a conditional version of current function object

auto operator()( floating_value auto x, floating_value auto y ) const noexcept;
auto operator()( floating_value auto x, floating_value auto... args ) const noexcept;
Definition: value.hpp:83