The naive complex division function here is not very accurate and sometimes fails the autotest assert. Probably there's something better... https://arxiv.org/pdf/1210.4539.pdf or https://arxiv.org/pdf/1608.07596.pdf Most complex division algorithms seem to have a branch however, which would take a bit of work to avoid.
| 435 | // Most complex division algorithms seem to have a branch however, which |
| 436 | // would take a bit of work to avoid. |
| 437 | static inline void |
| 438 | _inline_div( npy_complex64 a, npy_complex64 b, npy_complex64 &r) |
| 439 | { |
| 440 | npy_float32 d = 1.0f/(b.real*b.real + b.imag*b.imag); |
| 441 | r.real = (a.real*b.real + a.imag*b.imag)*d; |
| 442 | r.imag = (a.imag*b.real - a.real*b.imag)*d; |
| 443 | |
| 444 | } |
| 445 | static inline void |
| 446 | _inline_div( npy_complex128 a, npy_complex128 b, npy_complex128 &r) |
| 447 | { |