E.V.E  0.1-beta

◆ minabs

eve::minabs = {}
inlineconstexpr

Callable object computing the minabs operation.

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

Members Functions

Member Effect
operator() the minabs 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 greatest absolute value is returned.

For instance for two elements:

  • If |x| < |y|, |x| is returned.
  • If |x| > |y|, |y| is returned.
  • Otherwise min(|x|, |y|) is returned.

For n parameters the result is computed as if this scheme was recursively used.

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

    The behaviour is the same except that if |x| == |y|, pedantic(max) is used.

  • eve::numeric

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

    The behaviour is the same except that if |x| == |y|, numeric(max) is used.

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

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

    The expression diff< N >(minabs)(x,args,...) computes the partial derivative relative to the Nth parameter. If the parameters are \(x_1, ..., x_n\) and their minabs 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/minabs.hpp>
#include <eve/function/numeric/minabs.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'
<< "-> minabs(pf, qf) = " << eve::minabs(pf, qf) << '\n'
<< "-> pedantic(minabs)(pf, qf) = " << eve::pedantic(eve::minabs)(pf, qf) << '\n'
<< "-> numeric(minabs)(pf, qf) = " << eve::numeric(eve::minabs)(pf, qf) << '\n';
float xf = -4.0f;
float yf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> minabs(xf, yf) = " << eve::minabs(xf, yf) << '\n'
<< "-> pedantic(minabs)(xf, yf) = " << eve::pedantic(eve::minabs)(xf, yf) << '\n'
<< "-> numeric(minabs)(xf, yf) = " << eve::numeric(eve::minabs)(xf, yf) << '\n';
return 0;
}
constexpr callable_minabs_ minabs
Callable object computing the minabs operation.
Definition: minabs.hpp:104
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