File tree 2 files changed +8
-6
lines changed
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 {
38
38
39
39
/* reduce x into [-.25,.25] */
40
40
n = ( 4.0 * x) as isize ;
41
- n = ( n + 1 ) / 2 ;
41
+ n = div ! ( n + 1 , 2 ) ;
42
42
x -= ( n as f64 ) * 0.5 ;
43
43
44
44
x *= PI ;
@@ -118,18 +118,19 @@ fn s(x: f64) -> f64 {
118
118
/* to avoid overflow handle large x differently */
119
119
if x < 8.0 {
120
120
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 ) ;
123
123
}
124
124
} else {
125
125
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 ) ;
128
128
}
129
129
}
130
130
return num / den;
131
131
}
132
132
133
+ #[ cfg_attr( all( test, assert_no_panic) , no_panic:: no_panic) ]
133
134
pub fn tgamma ( mut x : f64 ) -> f64 {
134
135
let u: u64 = x. to_bits ( ) ;
135
136
let absx: f64 ;
@@ -157,7 +158,7 @@ pub fn tgamma(mut x: f64) -> f64 {
157
158
return 0.0 / 0.0 ;
158
159
}
159
160
if x <= FACT . len ( ) as f64 {
160
- return FACT [ ( x as usize ) - 1 ] ;
161
+ return i ! ( FACT , ( x as usize ) - 1 ) ;
161
162
}
162
163
}
163
164
Original file line number Diff line number Diff line change 1
1
use super :: tgamma;
2
2
3
+ #[ cfg_attr( all( test, assert_no_panic) , no_panic:: no_panic) ]
3
4
pub fn tgammaf ( x : f32 ) -> f32 {
4
5
tgamma ( x as f64 ) as f32
5
6
}
You can’t perform that action at this time.
0 commit comments