@@ -8,6 +8,8 @@ use super::super::pyobject::{
8
8
DictProtocol , PyContext , PyFuncArgs , PyObjectRef , PyResult , TypeProtocol ,
9
9
} ;
10
10
use super :: super :: VirtualMachine ;
11
+ use statrs:: function:: erf:: { erf, erfc} ;
12
+ use statrs:: function:: gamma:: { gamma, ln_gamma} ;
11
13
use std;
12
14
13
15
// Helper macro:
@@ -156,8 +158,7 @@ fn math_erf(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
156
158
if x. is_nan ( ) {
157
159
Ok ( vm. ctx . new_float ( x) )
158
160
} else {
159
- // TODO: implement algorithm
160
- unimplemented ! ( "TODO" ) ;
161
+ Ok ( vm. ctx . new_float ( erf ( x) ) )
161
162
}
162
163
}
163
164
@@ -168,8 +169,7 @@ fn math_erfc(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
168
169
if x. is_nan ( ) {
169
170
Ok ( vm. ctx . new_float ( x) )
170
171
} else {
171
- // TODO: implement algorithm
172
- unimplemented ! ( "TODO" ) ;
172
+ Ok ( vm. ctx . new_float ( erfc ( x) ) )
173
173
}
174
174
}
175
175
@@ -178,8 +178,7 @@ fn math_gamma(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
178
178
let x = objfloat:: get_value ( value) ;
179
179
180
180
if x. is_finite ( ) {
181
- // TODO: implement algorithm
182
- unimplemented ! ( "TODO" ) ;
181
+ Ok ( vm. ctx . new_float ( gamma ( x) ) )
183
182
} else {
184
183
if x. is_nan ( ) || x. is_sign_positive ( ) {
185
184
Ok ( vm. ctx . new_float ( x) )
@@ -194,8 +193,7 @@ fn math_lgamma(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
194
193
let x = objfloat:: get_value ( value) ;
195
194
196
195
if x. is_finite ( ) {
197
- // TODO: implement algorithm
198
- unimplemented ! ( "TODO" ) ;
196
+ Ok ( vm. ctx . new_float ( ln_gamma ( x) ) )
199
197
} else {
200
198
if x. is_nan ( ) {
201
199
Ok ( vm. ctx . new_float ( x) )
0 commit comments