E.V.E  0.1-beta

◆ prime_ceil

eve::prime_ceil = {}
inlineconstexpr

Callable object computing the least prime greater or equal to the input.

Required header: #include <eve/function/prime_ceil.hpp>

Members Functions

Member Effect
operator() unsigned integral prime_ceil
operator[] Construct a conditional version of current function object

auto operator()( unsigned_value auto n ) const noexcept;
Definition: value.hpp:63

Parameters

n: unsigned value.

Return value

The result element type is the same as the input one unless a converter is applied.

A binary search is performed using eve::nth_prime.

Warning
this function will return 0 (or nan) as soon as the input is greater than 104729.

auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::prime_ceil

Parameters

cond : conditional expression

Return value

A Callable object so that the expression prime_ceil[cond](x, ...) is equivalent to if_else(cond,prime_ceil(x, ...),x)


Supported converters

  • eve::float_, eve::double_, eve::floating_

    The expression d(prime_ceil)(x) where d in one of these 3 converters is supported and produce a floating point output.

Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/prime_floor.hpp>
#include <eve/function/prime_ceil.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
w32_t pi32 = {0, 6, 6542, 15, 104729, 104730, 10000, 1000};
std::cout << "---- simd" << '\n'
<< " <- pi32 = " << pi32 << '\n'
<< " -> prime_ceil(pi32) = " << eve::prime_ceil(pi32) << '\n'
<< " -> float32(prime_ceil)(pi32) = " << eve::float32(eve::prime_ceil)(pi32) << '\n';
std::uint32_t xi = 18;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " -> prime_ceil(xi) = " << eve::prime_ceil(xi) << '\n';
return 0;
}
constexpr callable_prime_ceil_ prime_ceil
Callable object computing the least prime greater or equal to the input.
Definition: prime_ceil.hpp:89
constexpr converter_type< float > const float32
convert a eve::real_value to a float32 based eve::floating_real_value.
Definition: converter.hpp:133
Wrapper for SIMD registers.
Definition: wide.hpp:65