E.V.E  0.1-beta

◆ div

eve::div = {}
inlineconstexpr

Callable object performing the division of multiple values.

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

Members Functions

Member Effect
operator() Computes the absolute value of its parameter
operator[] Construct a conditional version of current function object

auto operator()(eve::value auto const& x, eve::value auto const&... xs) const noexcept;
Definition: value.hpp:31

Parameters

x Instance of eve::value.

xs: Instances of eve::value. Behavior is undefined if the expected result type is integral and any xs is equal to 0.

Return value

A value of the common compatible type of x and all xs containing the elementwise division of x by all xs. The result is semantically equivalent to x/mul(xs...)

With two parameters, the call div(x, y) is equivalent to x / y if x or y is an simd value.

Warning
Although the infix notation with / is supported, the / operator on standard scalar types is the original one and so can lead to automatic promotion.

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

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

Parameters

cond : conditional expression

Return value

A Callable object so that the expression div[cond](x0,xs...) is equivalent to if_else(cond,div(x0,xs...),x0)


Supported decorators

Example

See it live on Compiler Explorer

#include <eve/function/div.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 2, 3, 32700}, qi = {4, 1, 1, 100};
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> div(pi, qi) = " << eve::div(pi, qi) << '\n'
<< " -> pi / qi = " << pi / qi << '\n';
std::int16_t xi = -32768, yi = -1;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> div(xi, yi) = " << eve::div(xi, yi) << '\n'
<< " -> xi / yi = " << xi / yi << '\n' // C++ promotion to int
<< " -> std::int16_t( xi / yi) = "<< std::int16_t( xi / yi) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr callable_div_ div
Callable object performing the division of multiple values.
Definition: div.hpp:118
Wrapper for SIMD registers.
Definition: wide.hpp:65