Computes the division of multiple values.
If the arguments are \((x_i)_{0\le i\le n}\) The value of \(x/\prod_1^n x_i\) is returned.
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wf_t pf = {3, 2, 3, 32700}, qf = {4, 1, 1, 100};
std::cout << "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<<
" -> div(pf, qf) = " <<
eve::div(pf, qf) <<
'\n'
<< " -> pf / qf = " << pf / qf << '\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'
<< " -> std::int16_t( xi / yi) = "<< std::int16_t( xi / yi) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65
Masked Call
The call eve::div[mask](x, ...)
provides a masked version of div
which is equivalent to if_else(mask, div(x, ...), x)
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wf_t pf = {31, 2, 3, 32700}, qf = {4, 8, 16, 100};
std::cout << "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<<
" -> div[pf > qf](pf, qf) = " <<
eve::div[pf > qf](pf, qf) <<
'\n';
return 0;
}
eve::saturated
The expression eve::saturated(eve::div)(x, xs...)
computes the saturated division of x
by all xs
. The result is semantically equivalent to saturated(div)(x, saturated(mul)(xs...))
but is always defined even if the denominator is 0.
The relevant cases are just in fact the division by 0 for integral types in which case the result is `eve::valmin(as(x))` or [eve::valmax(as(x))
](ref eve::valmax) according to the dividend sign, and the division of `eve::valmin(as(x))` by -1 that produces `eve::valmax(as(x))`.
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
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'
return 0;
}
constexpr saturated_type const saturated
Higher-order Callable Object imbuing saturation semantic onto other Callable Objects.
Definition: saturated.hpp:68
eve::toward_zero, eve::downward, eve::upward, eve::to_nearest
The calls d(div)(x, y)
where d is one of these 4 decorators produce respectively
* `eve::trunc (div(x, y))` for eve::toward_zero.
* `eve::floor (div(x, y))` for deve::downward.
* `eve::ceil (div(x, y))` for eve::upward.
* `eve::nearest (div(x,y))`for eve::to_nearest.
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wf_t pf = {3034, 200, 333, 32700}, qf = {4, 7, 13, 100};
std::cout << "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
return 0;
}
constexpr toward_zero_type const toward_zero
Higher-order Callable Object imbuing rounding toward zero semantic onto other Callable Objects.
Definition: roundings.hpp:163
constexpr upward_type const upward
Higher-order Callable Object imbuing upward rounding semantic onto other Callable Objects.
Definition: roundings.hpp:160
constexpr downward_type const downward
Higher-order Callable Object imbuing rounding downard semantic onto other Callable Objects.
Definition: roundings.hpp:161
constexpr to_nearest_type const to_nearest
Higher-order Callable Object imbuing rounding to nearest semantic onto other Callable Objects.
Definition: roundings.hpp:162