WPILibC++ 2023.4.3
incomplete_gamma_inv.hpp File Reference

Go to the source code of this file.

Namespaces

namespace  internal
 

Functions

template<typename T >
constexpr T internal::incomplete_gamma_inv_decision (const T value, const T a, const T p, const T direc, const T lg_val, const int iter_count) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_t_val_1 (const T p) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_t_val_2 (const T a) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_initial_val_1_int_begin (const T t_val) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_initial_val_1_int_end (const T value_inp, const T a) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_initial_val_1 (const T a, const T t_val, const T sgn_term) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_initial_val_2 (const T a, const T p, const T t_val) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_initial_val (const T a, const T p) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_err_val (const T value, const T a, const T p) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_deriv_1 (const T value, const T a, const T lg_val) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_deriv_2 (const T value, const T a, const T deriv_1) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_ratio_val_1 (const T value, const T a, const T p, const T deriv_1) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_ratio_val_2 (const T value, const T a, const T deriv_1) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_halley (const T ratio_val_1, const T ratio_val_2) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_recur (const T value, const T a, const T p, const T deriv_1, const T lg_val, const int iter_count) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_begin (const T initial_val, const T a, const T p, const T lg_val) noexcept
 
template<typename T >
constexpr T internal::incomplete_gamma_inv_check (const T a, const T p) noexcept
 
template<typename T1 , typename T2 , typename TC = common_return_t<T1,T2>>
constexpr TC internal::incomplete_gamma_inv_type_check (const T1 a, const T2 p) noexcept
 
template<typename T1 , typename T2 >
constexpr common_return_t< T1, T2 > incomplete_gamma_inv (const T1 a, const T2 p) noexcept
 Compile-time inverse incomplete gamma function. More...
 

Function Documentation

◆ incomplete_gamma_inv()

template<typename T1 , typename T2 >
constexpr common_return_t< T1, T2 > incomplete_gamma_inv ( const T1  a,
const T2  p 
)
constexprnoexcept

Compile-time inverse incomplete gamma function.

Parameters
aa real-valued, non-negative input.
pa real-valued input with values in the unit-interval.
Returns
Computes the inverse incomplete gamma function, a value \( x \) such that

\[ f(x) := \frac{\gamma(a,x)}{\Gamma(a)} - p \]

equal to zero, for a given p. GCE-Math finds this root using Halley's method:

\[ x_{n+1} = x_n - \frac{f(x_n)/f'(x_n)}{1 - 0.5 \frac{f(x_n)}{f'(x_n)} \frac{f''(x_n)}{f'(x_n)} } \]

where

\[ \frac{\partial}{\partial x} \left(\frac{\gamma(a,x)}{\Gamma(a)}\right) = \frac{1}{\Gamma(a)} x^{a-1} \exp(-x) \]

\[ \frac{\partial^2}{\partial x^2} \left(\frac{\gamma(a,x)}{\Gamma(a)}\right) = \frac{1}{\Gamma(a)} x^{a-1} \exp(-x) \left( \frac{a-1}{x} - 1 \right) \]