E.V.E
v2022.03.00

◆ agm

eve::agm = {}
inlineconstexpr

Computes the arithmetic-geometric mean.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T, eve::floating_value U >
eve::common_compatible_t<T, U> agm(T x, U y) noexcept;
}
constexpr callable_agm_ agm
Computes the arithmetic-geometric mean.
Definition: agm.hpp:61
Definition: all_of.hpp:22

Parameters

Return value

The value of the arithmetic-geometric mean is returned. No overflow can occur. The two parameters must share the same sign.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <vector>
#include <iostream>
int main()
{
wf_t pf = {3, 2, 3, 3};
wf_t qf = {4, 1, 1, eve::inf(eve::as<float>())};
std::cout << "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> agm(pf, qf) = " << eve::agm(pf, qf) << '\n';
double xi = 3, yi = 4;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> agm(xi, yi) = " << eve::agm(xi, yi) << '\n';
return 0;
}
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

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

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <vector>
    #include <iostream>
    int main()
    {
    wf_t pf = {3, 2, 4, 3};
    wf_t qf = {4, 1, 3, eve::inf(eve::as<float>())};
    std::cout << "---- simd" << '\n'
    << " <- pf = " << pf << '\n'
    << " <- qf = " << qf << '\n'
    << " -> agm[pf < qf](pf, qf) = " << eve::agm[pf < qf](pf, qf) << '\n';
    return 0;
    }