Computes the largest integer not greater than the input.
Defined in Header
#include <eve/module/core.hpp>
{
template< eve::value T >
}
constexpr callable_floor_ floor
Computes the largest integer not greater than the input.
Definition: floor.hpp:80
Parameters
Return value
The largest integer not greater than `x`.
The standard proposes 4 rounding modes namely: `FE_TONEAREST`, `FE_DOWNWARD`, `FE_UPWARD`,
`FE_TOWARDZERO`. This function object implements the `FE_DOWNWARD` version.
For complex inputs the floor operation is applied to both real and imaginary parts.
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, -1.3f, -1.5f, -1.7f, 2.0f, 2.3f, 2.5f, 2.7f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
float xf = -32.768f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65
Masked Call
The call eve;floor[mask](x)
provides a masked version of eve::floor
which is equivalent to if_else (mask, floor(x), x)
.
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, -1.3f, -1.5f, -1.7f, 2.0f, 2.3f, 2.5f, 2.7f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<<
"-> floor[pf > -1.5](pf) = " <<
eve::floor[pf > -1.5](pf) <<
'\n';
return 0;
}
eve::tolerant
The expression tolerant(floor)(x, tol)
computes a tolerant floor value for x
, where x
must be a floating value.
- If
tol
is a floating value, computes the floor with a tolerance tol
using Hagerty's FL5 function.
- If
tol
is an integral value n, computes the floor of the next nth representable value in the x
type.
- If
tol
is omitted, the tolerance is taken to 3 times the machine \(\epsilon\) in the x
type (3*eps(as(x))
).
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
wide_ft pf = {-1.0f, -1.3f, -1.5f, -1.7f, 2.0f, 2.3f, 2.5f, 2.7f};
std::cout << "---- simd" << std::setprecision(8) << '\n'
<< "<- pf = " << pf << '\n'
return 0;
}
constexpr callable_eps_ eps
Computes the the machine epsilon.
Definition: eps.hpp:63
constexpr tolerant_type const tolerant
Higher-order Callable Object imbuing a less strict semantic onto other Callable Objects.
Definition: fuzzy.hpp:147
Lightweight type-wrapper.
Definition: as.hpp:29