TGamma
Calculates the true gamma function.
template<FloatingPointType T>
constexpr inline T TGamma( T x ) noexcept;
Example/Test code
using C = Constants<double>;
constexpr auto Check = []( C::ValueType x, C::ValueType expected ) -> bool
{
auto r = TGamma( x );
return IsSameValue( r, expected );
};
constexpr auto CheckIsNaN = []( C::ValueType x ) -> bool
{
auto r = TGamma( x );
return IsNaN( r );
};
// tgamma (inf) == inf
constexpr auto check1 = Check( C::Infinity, C::Infinity );
BOOST_CHECK( check1 );
// tgamma (0) == inf
constexpr auto check2 = Check( C::Zero, C::Infinity );
BOOST_CHECK( check2 );
// tgamma (-0) == inf
constexpr auto check3 = Check( -C::Zero, C::Infinity );
BOOST_CHECK( check3 );
// tgamma (-2) == NaN
constexpr auto check4 = CheckIsNaN( -C::Two );
BOOST_CHECK( check4 );
// tgamma (-inf) == NaN
constexpr auto check5 = CheckIsNaN( -C::Infinity );
BOOST_CHECK( check5 );
// tgamma (NaN) == NaN
constexpr auto check6 = CheckIsNaN( C::NaN );
BOOST_CHECK( check6 );
// tgamma (0.5) == sqrt (pi)
constexpr auto check7 = Check( .5, Sqrt( C::Pi ) );
BOOST_CHECK( check7 );
// tgamma (-0.5) == -2 sqrt (pi)
constexpr auto check8 = Check( -.5, -2. * Sqrt( C::Pi ) );
BOOST_CHECK( check8 );
// tgamma (1) == 1
constexpr auto check9 = Check( 1., 1. );
BOOST_CHECK( check9 );
// tgamma (4) == 6
constexpr auto check10 = Check( 4., 6. );
BOOST_CHECK( check10 );
// tgamma (0.7) == 1.29805533264755778568
constexpr auto check11 = Check( 0.7, 1.29805533264755778568 );
BOOST_CHECK( check11 );
// tgamma (1.2) == 0.91816874239976054
constexpr auto check12 = Check( 1.2, 0.91816874239976054 );
auto res = TGamma( 1.2 );
BOOST_CHECK( check12 );