1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

add math::lgamma

This commit is contained in:
bolero-MURAKAMI 2013-04-23 19:03:03 +09:00
parent a55c430f09
commit 5f40808f75
58 changed files with 323 additions and 116 deletions

View file

@ -68,27 +68,19 @@ namespace sprout {
}
template<typename T>
inline SPROUT_CONSTEXPR T
tgamma_impl_2_pos(T x, T y, T t) {
tgamma_impl_2_pos_rec(T x, T y, T t) {
return t == 0 ? std::numeric_limits<T>::infinity()
: (x - T(1)) / y / t
;
}
template<typename T>
inline SPROUT_CONSTEXPR T
tgamma_impl_2_neg(T x, T y, T t) {
return t == 0 ? T(0)
: T(1) / y * t
;
}
template<typename T>
inline SPROUT_CONSTEXPR T
tgamma_impl_1(T x, int n) {
return n == 1 ? (x - T(1)) / sprout::math::detail::tgamma_impl_y(x - (n + 2))
: n == 0 ? T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2))
: n == static_cast<int>(sprout::math::factorial_limit<T>())
? sprout::math::detail::tgamma_impl_2_pos(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_pos_rec(x, 2, n + 1))
? sprout::math::detail::tgamma_impl_2_pos_rec(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_pos_rec(x, 2, n + 1))
: n == -static_cast<int>(sprout::math::factorial_limit<T>())
// ? sprout::math::detail::tgamma_impl_2_neg(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_neg_rec(x, 0, -n))
? T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) * sprout::math::detail::tgamma_impl_t_neg_rec(x, 0, -n)
: n > 1 ? (x - T(1)) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) * sprout::math::detail::tgamma_impl_t_pos(x, 2, n + 1)
: T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) / sprout::math::detail::tgamma_impl_t_neg(x, 0, -n)
@ -100,7 +92,7 @@ namespace sprout {
return sprout::math::detail::tgamma_impl_1(
x,
sprout::clamp(
sprout::math::iround(x - T(2)),
sprout::iround(x - T(2)),
-static_cast<int>(sprout::math::factorial_limit<T>()),
static_cast<int>(sprout::math::factorial_limit<T>())
)