Complex numbers: fast Cartesian-polar conversion

I am looking for a quick way to turn an array of complex numbers into a polar representation.

For example, given the complex number X, I want to turn it into a polar representation as follows:

  Q.phase    = atan2 (X.imag / X.real);
  Q.magniude = sqrt  (X.imag * X.imag + X.real * X.real);

I need to do this conversion about 400 thousand times per second on a fixed-point DSP. My numbers are in 1.15.16 fixed-point format, and I would like to save it that way.

DSP is very fast when I execute actions in unconditional loops, for example. when the number of cycles is known in advance. It scans when it has to make subroutine and division calls. Cached misses are also very slow, so I don’t want to use large lookup tables if possible (4k will be fine .. I can allocate some internal memory for this task).

I am currently processing atan2 as a polynomial approximation and using the well-known bitwise algorithm for an integer square root. It is not fast enough.

I have a feeling that there should be a more effective way to get the result. Maybe some of the calculations from sqrt and atan can be separated? Or is there an iterative way to get my results?

+3
1
+2

Source: https://habr.com/ru/post/1723592/


All Articles