-
Couldn't load subscription status.
- Fork 60
Open
Description
I'm attempting to use:
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:
fn fma<T: num::Float>(a: T, b: Complex<T>, c: Complex<T>) -> Complex<T> {
let re = a.mul_add(b.re, c.re);
let im = a.mul_add(b.im, c.im);
Complex::new(re, im)
}which does compile using two fused multiply adds which hopefully the compiler could reorder, vectorise or whatever optimisations it believes fruitful.
The code I'm writing (a convolution kernel) is attempting to be generic over real and complex numbers which relies on the num::Complex crate to provide this implementation.
My preferred solution would be for num::Complex to implement T::mul_add(Complex<T>, Complex<T>) -> Complex<T> where T: MulAdd<T, T, Output=T>
Metadata
Metadata
Assignees
Labels
No labels