E.V.E
v2022.09.01

◆ factorial

eve::factorial = {}
inlineconstexpr

Computes \(\displaystyle n! = \prod_{i=1}^n i\).

Defined in header

#include <eve/module/special.hpp>

Callable Signatures

namespace eve
{
template< eve::value N >
eve::as_floating_point_value<N> factorial(N x) noexcept;
}
constexpr callable_factorial_ factorial
Computes .
Definition: factorial.hpp:53
Definition: all_of.hpp:22

Parameters

Return value

The value of \( n!\) is returned.

Warning
This function will overflow as soon as the input is greater than 171 for integral or double entries and if the entry is greater than 34 for float.

Example

#include <eve/module/special.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
w32_t pi32 = {93, 25, 32, 180, 1, 2, 3, 4};
std::cout << "---- simd" << std::setprecision(17) << '\n'
<< " <- pi32 = " << pi32 << '\n'
<< " -> factorial(pi32) = " << eve::factorial(pi32) << '\n';
std::uint32_t xi = 18;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " -> factorial(xi) = " << eve::factorial(xi) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65