...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/math/special_functions/factorials.hpp>
namespace boost{ namespace math{ template <class T> calculated-result-type rising_factorial(T x, int i); template <class T, class Policy> calculated-result-type rising_factorial(T x, int i, const Policy&); }} // namespaces
Returns the rising factorial of x and i:
rising_factorial(x, i) = Γ(x + i) / Γ(x);
or
rising_factorial(x, i) = x(x+1)(x+2)(x+3)...(x+i-1)
Note that both x and i can be negative as well as positive.
The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.
May return the result of overflow_error if the result is too large to represent in type T.
The return type of these functions is computed using the result
type calculation rules: the type of the result is double
if T is an integer type, otherwise
the type of the result is T.
The accuracy will be the same as the tgamma_delta_ratio function.
The spot tests for the rising factorials use data generated by functions.wolfram.com.
Rising and falling factorials are implemented as ratios of gamma functions using tgamma_delta_ratio. Optimisations for small integer arguments are handled internally by that function.