Skip to main content

complex_multiply

Function complex_multiply 

Source
pub fn complex_multiply(ar: f32, ai: f32, br: f32, bi: f32) -> (f32, f32)
Expand description

Pointwise complex multiplication: (ar + i·ai) × (br + i·bi).

Returns (real, imag) where:

  • real = ar·br − ai·bi
  • imag = ar·bi + ai·br

§Examples

use oxigdal_gpu::convolution_fft::complex_multiply;

// (1+0i) * (1+0i) = 1
let (r, i) = complex_multiply(1.0, 0.0, 1.0, 0.0);
assert!((r - 1.0).abs() < 1e-6);
assert!(i.abs() < 1e-6);

// (0+1i) * (0+1i) = -1
let (r, i) = complex_multiply(0.0, 1.0, 0.0, 1.0);
assert!((r + 1.0).abs() < 1e-6);
assert!(i.abs() < 1e-6);