Computes the smallest integer not less than the input.
Defined in Header
#include <eve/module/core.hpp>
{
template< eve::value T >
}
constexpr callable_ceil_ ceil
Computes the smallest integer not less than the input.
Definition: ceil.hpp:80
Definition: all_of.hpp:22
Parameters
Return value
The smallest integer not less than x
.
The standard proposes 4 rounding modes namely: FE_TONEAREST
, FE_DOWNWARD
, FE_UPWARD
, FE_TOWARDZERO
. This function object implements the FE_UPWARD
version.
For complex inputs the ceil 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'
<<
"-> ceil(pf) = " <<
eve::ceil(pf) <<
'\n';
float xf = -32.768f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<<
"-> ceil(xf) = " <<
eve::ceil(xf) <<
'\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65
Masked Call
The call eve;ceil[mask](x)
provides a masked version of eve::ceil
which is equivalent to if_else (mask, ceil(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'
<<
"-> ceil[pf > -1.5f](pf) = " <<
eve::ceil[pf > -1.5f](pf) <<
'\n';
return 0;
}
eve::tolerant
The expression tolerant(ceil)(x, tol)
computes a tolerant ceil 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*eve::eps (eve::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 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