E.V.E
v2022.09.01

◆ maxabs

eve::maxabs = {}
inlineconstexpr

Computes the maximum of the absolute value of its arguments.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T, eve::value... Ts >
auto maxabs(T x, Ts ... xs) noexcept;
}
Definition: value.hpp:31
constexpr callable_maxabs_ maxabs
Computes the maximum of the absolute value of its arguments.
Definition: maxabs.hpp:84
Definition: all_of.hpp:22

Parameters

Return value

The value of the maximum of the absolute value of the arguments is returned.

Note
  • If any element of the inputs is a Nan, the corresponding output element is system-dependent.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, 1.0f, 1.0f, -2.0f, 2.0f,
wide_ft qf = {4.0f, 1.0f, -1.0f, 0.0f, -3.0f,
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> maxabs(pf, qf) = " << eve::maxabs(pf, qf) << '\n';
float xf = -4.0f;
float yf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> maxabs(xf, yf) = " << eve::maxabs(xf, yf) << '\n';
return 0;
}
constexpr callable_nan_ nan
Computes the IEEE NaN constant.
Definition: nan.hpp:53
constexpr callable_minf_ minf
Computes the -infinity ieee value.
Definition: minf.hpp:60
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::maxabs[mask](x, ...) provides a masked version of maxabs which is equivalent to if_else(mask, maxabs(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {0.0f, 1.0f, -1.0f, -2.0f, 2.0f,
    wide_ft qf = {4.0f, 1.0f, -1.0f, 0.0f, eve::nan(eve::as<float>()),
    -0.0f, eve::nan(eve::as<float>()), -2.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> maxabs[pf < 0](pf, qf) = " << eve::maxabs[pf > 0](pf, qf) << '\n';
    return 0;
    }
    constexpr pedantic_type const pedantic
    Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
    Definition: pedantic.hpp:56
  • eve::pedantic, eve::numeric

    • The call pedantic(maxabs)(x,args,...) ensures the conformity to the standard behaviour, that is for two parameters (on an elementwise basis) to be semanticaly equivalent to: (|x| < |y|) ? |y| : |x| and this behaviour is also ensured on n parameters calls as if this scheme was recursively used.
    • The call numeric(maxabs)(x,args,...) ensures that if any element of the inputs is not a Nan, the corresponding output element will not be a Nan.

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {0.0f, 1.0f, 1.0f, -2.0f, 2.0f,
    wide_ft qf = {4.0f, 1.0f, -1.0f, 0.0f, -3.0f,
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> pedantic(maxabs)(pf, qf) = " << eve::pedantic(eve::maxabs)(pf, qf) << '\n'
    << "-> numeric(maxabs)(pf, qf) = " << eve::numeric(eve::maxabs)(pf, qf) << '\n';
    return 0;
    }
    constexpr numeric_type const numeric
    Higher-order Callable Object imbuing non invalid return preference semantic onto other Callable Objec...
    Definition: numeric.hpp:53