Computes a a bitwise reinterpretation of an object.
Computes the saturation of a value in a type.
Defined in Header
#include <eve/module/core.hpp>
{
{ template<value From, scalar_value To>
}
constexpr callable_bit_cast_ bit_cast
Computes a a bitwise reinterpretation of an object.
Definition: bit_cast.hpp:64
Definition: all_of.hpp:22
Lightweight type-wrapper.
Definition: as.hpp:29
Parameters
Template parameters
- To: scalar type to which each element of
x
is casted
Return value
The bits of x of type From reinterpreted as being those of a variable of type To is returned.
Every bit in the value representation of the returned To object is equal to the corresponding bit in the object representation of from. The values of padding bits in the returned To object are unspecified.
If there is no value of type To corresponding to the value representation produced, the behavior is undefined. If there are multiple such values, which value is produced is unspecified.
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
using iT = std::int32_t;
int main()
{
wide_ft pf = {1.0f, 2.0f, -1.0f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> eve::bit_cast(pf,as<wide_it>()) = " << std::hex << eve::bit_cast(pf, eve::as<wide_it>()) << '\n';
float xf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> eve::bit_cast(xf, as<iT>()) = " << std::hex << eve::bit_cast(xf, eve::as<iT>()) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65
Defined in Header
#include <eve/module/core.hpp>
{
{ template<value From, scalar_value To>
}
Parameters
Template parameters
- To: scalar type to which each element of
x
is saturated
Return value
For an x
of real value Target
, the call saturate(x, as_<Target>{})
returns elementwise a value of type Target which is the conversion of x
clamped between the smallest and largest values of Target
- Note
- Saturation operated by eve::saturate may lead to Undefined Behaviors if it implies conversions that are themselves U.B.
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 2.3f, 45000.7f, -64768.6f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> saturate(pf, int_64()_) = " << eve::saturate(pf, int_64()) << '\n'
<< "-> saturate(pf, int_16()) = " << eve::saturate(pf, int_16()) << '\n'
<<
"<- pi = " <<
pi <<
'\n'
<<
"-> saturate(pi, as(eve::as<double>())) = " << eve::saturate(
pi,
eve::as<double>()) <<
'\n';
double xf = -64768.4f;
std::int64_t xi = -64768;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> saturate(xf, int_64()) = " << eve::saturate(xf, int_64()) << '\n'
<< "<- xi = " << xi << '\n'
<<
"-> saturate(xi, as(eve::as<double>())) = " << eve::saturate(xi,
eve::as<double>()) <<
'\n';
return 0;
}
constexpr callable_valmax_ valmax
Computes the the greatest representable value.
Definition: valmax.hpp:55
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49