E.V.E
v2022.09.01

◆ max

eve::max = {}
inlineconstexpr

Computes the maximum of its arguments.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T, eve::value... Ts >
eve::common_compatible_t<T, Ts...> max(T x, Ts ... xs) noexcept;
}
Definition: value.hpp:31
constexpr callable_max_ max
Computes the maximum of its arguments.
Definition: max.hpp:85
Definition: all_of.hpp:22

Parameters

Return value

The value of the maximum 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, eve::nan(eve::as<float>()),
-0.0f, eve::nan(eve::as<float>()), -2.0f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> max(pf, qf) = " << eve::max(pf, qf) << '\n';
float xf = 1.0f;
float yf = eve::nan(eve::as<float>());
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> max(xf, yf) = = " << eve::max(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
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::max[mask](x, ...) provides a masked version of max which is equivalent to if_else(mask, max(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'
    << "-> maxmag[pf < 0](pf, qf) = " << eve::maxmag[pf < 0](pf, qf) << '\n';
    return 0;
    }
    constexpr callable_maxmag_ maxmag
    Computes the maximum of the absolute value of its arguments.
    Definition: maxmag.hpp:85
  • eve::pedantic, eve::numeric

    • The call pedantic(max)(x,args,...) ensures the conformity to the standard behaviour, that is for two parameters (on an elementwise basis) to be semantically 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(max)(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, eve::nan(eve::as<float>()),
    -0.0f, eve::nan(eve::as<float>()), -2.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> pedantic(max)(pf, qf) = " << eve::pedantic(eve::max)(pf, qf) << '\n'
    << "-> numeric(max)(pf, qf) = " << eve::numeric(eve::max)(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