E.V.E  0.1-beta

◆ manhattan

eve::manhattan = {}
inlineconstexpr

Callable object computing the manhattan operation.

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

Members Functions

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

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

Parameters

x, args: value

Return value

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


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

    The call pedantic(manhattan)(x,args... computes the sum of the absolute values of its parameters returning \(\infty\) as soon as one of its parameter is infinite, regardless of possible Nan values.

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

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

    The expression diff_< N >(manhattan)(x,args...) computes the partial derivative of the function relative to its Nth parameter. The returned value is 0 if N is greater that the actual number of parameters, otherwise it is the sign of the Nth parameter value.

!!! Warning This is only available for floating point entries.

Example

See it live on Compiler Explorer

#include <eve/function/manhattan.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 2.0f, -3.0f, -32768.0f};
wide_ft qf = {-4, 3, -2, -12};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> eve::manhattan(pf, qf) = " << eve::manhattan(pf, qf) << '\n';
float xf = -32768.0f;
float yf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> eve::manhattan(xf, yf) = " << eve::manhattan(xf, yf) << '\n';
return 0;
}
constexpr callable_manhattan_ manhattan
Callable object computing the manhattan operation.
Definition: manhattan.hpp:89
Wrapper for SIMD registers.
Definition: wide.hpp:65