Skip to content

Conversation

@singalsu
Copy link
Collaborator

No description provided.

* fmt=['static int32_t sqrt_int32_lut[] = {' repmat(' %d,',1, numel(lut)-1) ' %d};\n'];
* fprintf(fmt, lut)
*/
static int32_t sqrt_int32_lut[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static const

The rename is done to avoid possible conflict with other math
libraries. The change is done to prepare add of 32 bit square root
function.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds a higher precision 32-bit fractional integer
square root function to SOF math library. The algorithm uses
a lookup table for initial value and two iterations with
Newton-Raphson method to improve the accuracy. Both input and
output format is Q2.30. The format was chosen to match complex
to polar conversions numbers range for Q1.31 complex values.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch helps with more generic use of complex numbers not
directly related to the FFTs domain. It prepares to add polar
complex numbers format that is commonly used in frequency domain
signal processing.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds functions sofm_icomplex32_to_polar() and
sofm_ipolar32_to_complex(). In polar format the Q1.31
(real, imag) numbers pair is converted to (magnitude, angle).
The magnitude is Q2.30 format and angle in -pi to +pi radians
in Q3.29 format.

The conversion to polar and back loses some quality so there
currently is no support for icomplex16.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The new ztest cases test_icomplex32_to_polar and
ipolar32_to_complex test the conversion functions with a
pre-calculated -1,+1 box saturated (re, im) spiral shape with
1000 points.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds to stft_process component conversion to polar
(magnitude, angle) format for first FFT half from DC to Nyquist
frequency. The polar format is converted back to (real, imaginary)
complex and upper FFT half symmetry is applied. The magnitude domain
is commonly used for signal processing in frequency domain.

This change when enabled in Kconfig change increases load in MTL
platform from 72 MCPS to 202 MCPS with 1024 size FFT and hop of
256. Currently the build option STFT_PROCESS_MAGNITUDE_PHASE is
not set.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu force-pushed the add_complex_polar_convert branch from bce13a4 to 2f173e0 Compare January 27, 2026 12:15
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far.

* fmt=['static const int32_t sqrt_int32_lut[] = {' repmat(' %d,',1, numel(lut)-1) ' %d};\n'];
* fprintf(fmt, lut)
*/
static const int32_t sqrt_int32_lut[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to vector align this table for SIMD ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants