num-complex
num-complex copied to clipboard
Complex numbers for Rust
I propose to add the complex variant of the real $\mathrm{cis}$ function. It would be defined as $\mathrm{cis}\colon\mathbb{C}\to\mathbb{C}$ with $$\mathrm{cis}(z) = \exp(iz) = \exp(-\mathrm{Im}(z))\mathrm{cis}(\mathrm{Re}(z))$$ This complex $\mathrm{cis}$ function has applications...
In the current implementation, computing the argument of a complex number depends on the system math library's implementation of `atan2`, which is not guaranteed to produce exactly rounded (or otherwise...
In various circumstances, -0 has an extra plus sign appended where it should not: ```rs use num::complex::Complex; fn main() { println!("{}", Complex::new(-0.0, -0.0)); println!("{:+}", Complex::new(-0.0, -0.0)); } ``` ``` -0+-0i...
I'm attempting to use: ```rust println!("{:?}", (2.0_f32).mul_add( Complex::new(3.0_f32, 4.0_f32), Complex::new(5.0_f32, 6.0_f32))); ``` which doesn't exist. I think the equivalent would be: ```rust fn fma(a: T, b: Complex, c: Complex) ->...
Adds the missing three implementations for mixed Complex and Real `MulAdd` trait. I see it was noted in #37 that there would be 8 total, and you did not want...
Implements the `Checked[Add,Sub,Mul,Div,Rem]` traits from `num_traits`.
Closes #136 . This adds the `.cis()` method for `Float` and `Complex`. Adding it as a trait-based method allows for overloading compared to a free standing implementation. The Float version...
Closes #138 . Implemtented explicitly checking for zero values to treat floating-point zeros better. Positive and negative zeros are both treated as the same (positive) zero value. Differentiating between both...
Closes #140 . This introduced the method `Complex::from_real()` as discussed in #140. Alongside a test is added.
Closes #148 . Makes use of nested FMA calls. Needs additional `Neg` trait bound (previously `Sub` bound was implicitly assumed).