15template <detail::native_math::NativeReal R, detail::MathInteger I> R
factorial(I n)
17 auto order = detail::math_integer(n);
18 if (order < 0)
throw std::domain_error(
"factorial requires a nonnegative order");
20 if (order > L::max_exponent)
return L::infinity();
22 for (std::int64_t k = 2; k <= order; ++k)
29 R error = std::fma(high, factor, -
product) + low * factor;
41 require_precision<R>(
p);
42 return uni20::factorial<R>(n);
49template <
class R, detail::MathInteger I>
50 requires std::same_as<R, mpreal>
Exact arithmetic or an explicit binary working precision.
Definition core/precision.hpp:13
T product(std::vector< T > const &values)
Definition mpreal_exact_example.cpp:13
Definition data_table.cpp:8
Definition async/async.hpp:26
void sum(BackendSelector selector, async::Async< OutputTensor > &output, async::Async< InputTensor > const &input)
Schedule a full sum into an explicit async scalar tensor.
Definition linalg/async/reductions.hpp:309
R factorial(I n)
Factorial of a checked nonnegative integer, with an explicit native result type.
Definition factorial.hpp:15
Project-level numeric limits customization point.
Definition numeric_limits.hpp:16