Computes the remainder after division.
{
template< eve::value T, eve::value U>
}
constexpr callable_rem_ rem
Computes the remainder after division.
Definition: rem.hpp:106
typename eve::detail::common_value_impl< void, Ts... >::type common_value_t
Computes the SIMD-compatible common type between all Ts.
Definition: common_value.hpp:50
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t
pi = {3, 2, 3, 32700}, qi = {4, 2, 2, 101};
std::cout << "---- simd" << '\n'
<<
" <- pi = " <<
pi <<
'\n'
<< " <- qi = " << qi << '\n'
<<
" -> rem(pi, qi) = " <<
eve::rem(
pi, qi) <<
'\n'
<<
" -> pi % qi = " <<
pi % qi <<
'\n';
std::int16_t xi = 32700, yi = 101;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<<
" -> rem(xi, yi) = " <<
eve::rem(xi, yi) <<
'\n'
<< " -> xi % yi = " << xi % yi << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65
Masked Call
The call eve::rem[mask](x, ...)
provides a masked version of rem
which is equivalent to if_else(mask, rem(x, ...), x)
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t
pi = {3, 2, 3, 32700}, qi = {4, 2, 0, 101};
std::cout << "---- simd" << '\n'
<<
" <- pi = " <<
pi <<
'\n'
<< " <- qi = " << qi << '\n'
<<
" -> rem[qi!= 0](pi, qi) = " <<
eve::rem[qi!= 0](
pi, qi) <<
'\n';
return 0;
}
eve::toward_zero
The call toward_zero(rem)(x, y)
computes x-towardzero_(div)(x, y)*y
. For floating point entries this call is similar to std::fmod. In particular:
- If
x
is \(\pm0\) and y is not zero, \(\pm0\) is returned.
- If
x
is \(\pm\infty\), and y is not NaN, NaN is returned.
- If
y
is \(\pm0\), NaN is returned.
- If
y
is \(\pm\infty\) and x
is finite, x
is returned.
- If either argument is a Nan, NaN is returned.
eve::downward
The call downward(rem)(x, y)
computes x-downward(div)(x, y)*y
.
eve::upward
The call upward(rem)(x, y)
computes x-upward(div)(x, y)*y
. It is not defined for unsigned values as the result can be negative.
eve::to_nearest
The call to_nearest(rem)(x, y)
computes x-to_nearest(div)(x,y)*y
. It is not defined for unsigned values as the result can be negative. For floating point entries this call is similar to std::remainder. In particular:
- If
x
is \(\pm\infty\), NaN is returned
- If
y
is \(\pm0\), NaN is returned
- If either argument is a Nan, NaN is returned
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t
pi = {3, 2, 3, 32700}, qi = {4, 2, 2, 101};
std::cout << "---- simd" << '\n'
<<
" <- pi = " <<
pi <<
'\n'
<< " <- qi = " << qi << '\n'
<<
" -> pi % qi = " <<
pi % qi <<
'\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