E.V.E
v2023.02.15
Loading...
Searching...
No Matches
◆
nth_prime
auto eve::nth_prime =
functor
<nth_prime_t>
inline
constexpr
Header file
#include <eve/module/combinatorial.hpp>
Callable Signatures
namespace
eve
{
constexpr
auto
nth_prime
(
unsigned_value
auto
x) ->
decltype
(x)
noexcept
;
//1
template
<
int
egral_value T,
float
ing_scalar_value U>
constexpr
as_wide_as_t<U, T>
nth_prime
(T x,
as<U>
)
noexcept
;
//2
template
<
int
egral_value T,
unsigned
_scalar_value U>
constexpr
as_wide_as_t<U, T>
nth_prime
(T x,
as<U>
)
noexcept
;
//2
}
eve::unsigned_value
The concept unsigned_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition
value.hpp:84
eve::nth_prime
constexpr auto nth_prime
Returns the nth prime number.
Definition
nth_prime.hpp:86
eve
EVE Main Namespace.
Definition
abi.hpp:18
eve::as
Lightweight type-wrapper.
Definition
as.hpp:29
Parameters
n
: unsigned argument. If n is greater than 10'000, behavior is undefined.
Return value
The nth prime is returned.
Same, but the element type of the result is deduced from U.
Notes
2 is the first prime. It is returned for n=0.
Almost no computations are made, the results are from a lookup table.
External references
Wikipedia: Prime number
Example
// revision 1
#include <eve/module/combinatorial.hpp>
#include <iostream>
eve::wide<std::uint32_t>
wu([](
auto
i,
auto
)->std::uint32_t{
return
i;});
eve::wide
n{52u, 53u, 6541u, 6542u, 0u, 1u, 999u, 10000u};
int
main(){
std::cout <<
"<- wu = "
<< wu <<
"\n"
;
std::cout <<
"<- n = "
<< n <<
"\n"
;
std::cout <<
"-> nth_prime(wu)= "
<<
eve::nth_prime
(wu) <<
"\n"
;
std::cout <<
"-> nth_prime(n) = "
<<
eve::nth_prime
(n) <<
"\n"
;
}
eve::wide
Wrapper for SIMD registers.
Definition
wide.hpp:86
eve