Closed JorisDeRidder closed 2 years ago
The following code
use num::complex::Complex; fn main() { let z = Complex::<f64>::new(f64::NEG_INFINITY, f64::INFINITY); println!("z = {:?}", z); println!("exp(z) = {:?}", z.exp()); }
returns
z = Complex { re: -inf, im: inf } exp(z) = Complex { re: NaN, im: NaN }
while its C++ equivalent
#include <iostream> #include <complex> using namespace std; int main() { complex<double> z(-INFINITY, INFINITY); cout << "z = " << z << endl; cout << "exp(z) = " << exp(z) << endl; return 0; }
returns a different outcome:
z = (-inf,inf) exp(z) = (0,0)
Might it be that the special values are not properly implemented in num?
num
You're right, it is not trying to handle "special" values at all, directly computing: ea + i b = ea (cos(b) + i sin(b))
Fixed by #104.
The following code
returns
while its C++ equivalent
returns a different outcome:
Might it be that the special values are not properly implemented in
num
?