Hello,
I started to use the CMSIM DSP library and I have a question regarding the function "arm_cmplx_mag_q31()" that computes the complex magnitude. The function is basically implemented by the code below. Don't we loose about half of the precision by squaring and shifting the intermediate result by 33 bits? If I use the function with small numbers the result is obviously always zero or am I understanding something wrong? Are there any alternative ways in CMSIS to get the magnitude with the same precision as the input values?
Regards
Matthias
The function might be able to be improved by adding acc0 and acc1 before downshifting all 33 bits (would have to downshift once or saturate the addition). Or if a sqrt q63 was written, then the precision could be maintained longer. I'll look into it, and see if an improved version can make it in a future release.
You might implement your own q63 sqrt in the mean time if you want to use it in your project