E.V.E  0.1-beta

◆ minmag

eve::minmag = {}
inlineconstexpr

Callable object computing the minmag operation.

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

Members Functions

Member Effect
operator() the minmag 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, y: values

Return value

the elementwise element of least absolute value is returned.

For instance for two elements:

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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

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

  • eve::numeric

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

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

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

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

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

Example

See it live on Compiler Explorer

#include <eve/function/minmag.hpp>
#include <eve/function/saturated/minmag.hpp>
#include <eve/function/numeric/minmag.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'
<< "-> minmag(pf, qf) = " << eve::minmag(pf, qf) << '\n'
<< "-> saturated(minmag)(pf, qf) = " << eve::saturated(eve::minmag)(pf, qf) << '\n'
// << "-> numeric(minmag)(pf, qf) = " << eve::numeric(eve::minmag)(pf, qf) << '\n'
;
float xf = -4.0f;
float yf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> minmag(xf, yf) = " << eve::minmag(xf, yf) << '\n'
<< "-> saturated(minmag)(xf, yf) = " << eve::saturated(eve::minmag)(xf, yf) << '\n'
// << "-> numeric(minmag)(xf, yf) = " << eve::numeric(eve::minmag)(xf, yf) << '\n'
;
return 0;
}
constexpr callable_minmag_ minmag
Callable object computing the minmag operation.
Definition: minmag.hpp:102
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 saturated_type const saturated
Higher-order Callable Object imbuing saturation semantic onto other Callable Objects.
Definition: saturated.hpp:68
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65