E.V.E  0.1-beta

◆ absmax

eve::absmax = {}
inlineconstexpr

Callable object computing the absmax operation.

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

Members Functions

Member Effect
operator() the absmax 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

the elementwise absolute value of the maximum is returned.

The call absmax(x, args...) is equivalent to abs(max(x, args...))

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::absmax

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

    The call eve::pedantic(eve::absmax)(x, args...) is equivalent to eve::abs(eve::pedantic(eve::max)(x, args...))

  • eve::numeric

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

    The call eve::numeric(eve::absmax)(x, args...) is equivalent toeve::abs(eve::numeric(eve::max)(x, args...))`

  • eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_3rd, eve::diff_nth

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

    The expression diff_nth<N>(absmax)(x,args,...) computes the partial derivative relative to the Nth parameter. If the parameters are \(x_1, ..., x_n\) and their absmax is \(m\), the value returned is elementwise \(\mathrm{sign}(x_N)\) if \(m\) is equal to \(|x_N|\) else 0.

Example

See it live on Compiler Explorer

#include <eve/function/maxmag.hpp>
#include <eve/function/pedantic/absmax.hpp>
#include <eve/function/numeric/absmax.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, -3.0f,
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> absmax(pf, qf) = " << eve::absmax(pf, qf) << '\n'
<< "-> pedantic(absmax)(pf, qf) = " << eve::pedantic(eve::absmax)(pf, qf) << '\n'
<< "-> numeric(absmax)(pf, qf) = " << eve::numeric(eve::absmax)(pf, qf) << '\n';
float xf = -4.0f;
float yf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> absmax(xf, yf) = " << eve::absmax(xf, yf) << '\n'
<< "-> pedantic(absmax)(xf, yf) = " << eve::pedantic(eve::absmax)(xf, yf) << '\n'
<< "-> numeric(absmax)(xf, yf) = " << eve::numeric(eve::absmax)(xf, yf) << '\n';
return 0;
}
constexpr callable_absmax_ absmax
Callable object computing the absmax operation.
Definition: absmax.hpp:99
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