This repository was archived by the owner on Apr 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ fn sinpi(mut x: f64) -> f64 {
3838
3939 /* reduce x into [-.25,.25] */
4040 n = ( 4.0 * x) as isize ;
41- n = ( n + 1 ) / 2 ;
41+ n = div ! ( n + 1 , 2 ) ;
4242 x -= ( n as f64 ) * 0.5 ;
4343
4444 x *= PI ;
@@ -118,18 +118,19 @@ fn s(x: f64) -> f64 {
118118 /* to avoid overflow handle large x differently */
119119 if x < 8.0 {
120120 for i in ( 0 ..=N ) . rev ( ) {
121- num = num * x + SNUM [ i ] ;
122- den = den * x + SDEN [ i ] ;
121+ num = num * x + i ! ( SNUM , i ) ;
122+ den = den * x + i ! ( SDEN , i ) ;
123123 }
124124 } else {
125125 for i in 0 ..=N {
126- num = num / x + SNUM [ i ] ;
127- den = den / x + SDEN [ i ] ;
126+ num = num / x + i ! ( SNUM , i ) ;
127+ den = den / x + i ! ( SDEN , i ) ;
128128 }
129129 }
130130 return num / den;
131131}
132132
133+ #[ cfg_attr( all( test, assert_no_panic) , no_panic:: no_panic) ]
133134pub fn tgamma ( mut x : f64 ) -> f64 {
134135 let u: u64 = x. to_bits ( ) ;
135136 let absx: f64 ;
@@ -157,7 +158,7 @@ pub fn tgamma(mut x: f64) -> f64 {
157158 return 0.0 / 0.0 ;
158159 }
159160 if x <= FACT . len ( ) as f64 {
160- return FACT [ ( x as usize ) - 1 ] ;
161+ return i ! ( FACT , ( x as usize ) - 1 ) ;
161162 }
162163 }
163164
Original file line number Diff line number Diff line change 11use super :: tgamma;
22
3+ #[ cfg_attr( all( test, assert_no_panic) , no_panic:: no_panic) ]
34pub fn tgammaf ( x : f32 ) -> f32 {
45 tgamma ( x as f64 ) as f32
56}
You can’t perform that action at this time.
0 commit comments