E.V.E
v2022.03.00

◆ lfactorial

eve::lfactorial = {}
inlineconstexpr

Computes the natural logarithm of the factorial of unsigned integer values \(\displaystyle \log n! = \sum_{i=1}^n \log i\).

Defined in header

#include <eve/module/special.hpp>

Callable Signatures

namespace eve
{
template< eve::value N >
auto lfactorial(N x) noexcept;
}
constexpr callable_lfactorial_ lfactorial
Computes the natural logarithm of the factorial of unsigned integer values .
Definition: lfactorial.hpp:55
Definition: all_of.hpp:22

Parameters

Return value

The value of \( \log n!\) is returned with the following considerations:

  • If the entry is an [integral value](eve::integral_value), the result [element type](eve::element_type) is always double to try to avoid overflow.
  • If the entry is a [floating point value](eve::floating_point_value) which must be a flint, the result is of the same type as the entry.
  • If n elements are not integer or flint the result is undefined.

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'
<< " -> lfactorial(pi32) = " << eve::lfactorial(pi32) << '\n';
std::uint32_t xi = 18;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " -> lfactorial(xi) = " << eve::lfactorial(xi) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65