E.V.E  0.1-beta

◆ max

eve::max = {}
inlineconstexpr

Callable object computing the max operation.

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

Members Functions

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

template< value T, value ...Ts> auto operator()( T x,Ts... args ) const noexcept
requires (compatible_values< T, Ts > && ...);
Definition: value.hpp:31

Parameters

x, args: values

Return value

Computes the elementwise maximum of the parameters.

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

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

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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

    The call pedantic(max)(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.

  • eve::numeric

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

    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.

  • eve::diff, eve::diff_1st, eve::diff_nth

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

    The expression diff< N >(max)(x,args,...) computes the partial derivative relative to the Nth parameter. If the parameters are \(x_1, ..., x_n\) and their maximum is \(m\), the value returned is 1 if \(m\) is equal to \(x_N\) and otherwise 0.

Example

See it live on Compiler Explorer

#include <eve/function/max.hpp>
#include <eve/function/pedantic/max.hpp>
#include <eve/function/numeric/max.hpp>
#include <eve/wide.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/nan.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'
<< "-> pedantic(max)(pf, qf) = " << eve::pedantic(eve::max)(pf, qf) << '\n'
<< "-> numeric(max)(pf, qf) = " << eve::numeric(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'
<< "-> pedantic(max)(xf, yf) = " << eve::pedantic(eve::max)(xf, yf) << '\n'
<< "-> numeric(max)(xf, yf) = " << eve::numeric(eve::max)(xf, yf) << '\n';
return 0;
}
constexpr callable_max_ max
Callable object computing the max operation.
Definition: max.hpp:101
constexpr callable_nan_ nan
Callable object computing the nan value.
Definition: nan.hpp:52
constexpr callable_minf_ minf
Callable object computing the negative infinity value.
Definition: minf.hpp:55
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
constexpr numeric_type const numeric
Higher-order Callable Object imbuing non invalid return preference semantic onto other Callable Objec...
Definition: numeric.hpp:52
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65