E.V.E  0.1-beta

◆ double_factorial

eve::double_factorial = {}
inlineconstexpr

Callable object computing unsigned integral double_factorial.

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

Members Functions

Member Effect
operator() unsigned integral double_factorial

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

Parameters

n: unsigned value.

Return value

double factorial is defined by \(\displaystyle (2n)!! = \prod_{i=1}^n (2i)\) and \(\displaystyle (2n+1)!! = \prod_{i=0}^n (2i+1)\)

The result element type is always double to try to avoid overflow and its cardinal is the same as the entry in case of an simd call.

Warning
this function will overflow as soon as the input is greater than 300.

Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/double_factorial.hpp>
#include <eve/wide.hpp>
#include <iomanip>
#include <iostream>
int main()
{
w32_t pi32 = {1, 2, 3, 4, 5, 6, 181, 182};
std::cout << "---- simd" << std::setprecision(17) << '\n'
<< " <- pi32 = " << pi32 << '\n'
<< " -> double_factorial(pi32) = " << eve::double_factorial(pi32) << '\n';
std::uint32_t xi = 18;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " -> double_factorial(xi) = " << eve::double_factorial(xi) << '\n';
return 0;
}
constexpr callable_double_factorial_ double_factorial
Callable object computing unsigned integral double_factorial.
Definition: double_factorial.hpp:65
Wrapper for SIMD registers.
Definition: wide.hpp:65