File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub fn ln_gamma_approx(z: f64) -> f64 {
2626 if z <= 0.0 && z. fract ( ) == 0.0 {
2727 return f64:: INFINITY ;
2828 }
29-
29+
3030 if z < 0.5 {
3131 return PI . ln ( ) - ( PI * z) . sin ( ) . abs ( ) . ln ( ) - ln_gamma_approx ( 1.0 - z) ;
3232 }
@@ -42,18 +42,19 @@ pub fn ln_gamma_approx(z: f64) -> f64 {
4242}
4343
4444pub fn gamma_approx ( z : f64 ) -> f64 {
45- if z > 1f64 {
46- let z_int = z as usize ;
47- if z - ( z_int as f64 ) == 0f64 {
48- return factorial ( z_int - 1 ) as f64 ;
45+ if z <= 0.0 && z. fract ( ) == 0.0 {
46+ if z == 0.0 {
47+ return f64:: INFINITY ;
48+ } else {
49+ return f64:: NAN ;
4950 }
5051 }
5152
5253 if z < 0.5 {
53- PI / ( ( PI * z) . sin ( ) * gamma_approx ( 1f64 - z) )
54- } else {
55- ln_gamma_approx ( z) . exp ( )
54+ return PI / ( ( PI * z) . sin ( ) * gamma_approx ( 1f64 - z) ) ;
5655 }
56+
57+ ln_gamma_approx ( z) . exp ( )
5758}
5859
5960/// Lanczos Approximation Coefficient
You can’t perform that action at this time.
0 commit comments