◆ stirling()

Value boost::simd::stirling ( Value const &  x)

This function object computes an approwimation of the gamma function using the Stirling formula: \(\sqrt{2 \pi} x^{x-\frac12} e^{-x} ( 1 + \frac1{x} P(\frac1{x}))\), where \(P\) is a polynomial.

See also
gamma, gammaln
Header <boost/simd/function/stirling.hpp>
Example:
#include <boost/simd/eulerian.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_fd = bs::pack <double, 4>;
int main() {
pack_fd pd = {170.0, 2.0, 35.0, 10.0};
std::cout
<< "---- simd" << '\n'
<< "<- pd = " << pd << '\n'
<< "-> bs::stirling(pd) = " << bs::stirling(pd) << '\n';
double xf = 40.0;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::stirling(xf) = " << bs::stirling(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pd = (170, 2, 35, 10)
-> bs::stirling(pd) = (4.26907e+304, 1, 2.95233e+38, 362880)
---- scalar
<- xf = 40
-> bs::stirling(xf) = 2.03979e+46