colorchord icon indicating copy to clipboard operation
colorchord copied to clipboard

Improving accuracy in goutbins calc in DFT32.c

Open bbkiwi opened this issue 5 years ago • 2 comments

bbkiwi avatar Jul 04 '19 06:07 bbkiwi

In the orginal code isps and ispc loose 16 bits accuracy to prevent overflow at line 197 when they are squared. With the APPROXNORM == 1 option this was not neccessary. However isps and ispc are also used to compute goutbins in the non-CCEMBEDDED case. With floating point calculations the higher accuracy values should be used. I think it would be better to always compute isps and ispc as in lines 172 and 173 irregardless of APPROXNORM. Calculate 185 by float mux = ( ((float)isps) * ((float)isps)) + (((float)ispc) * ((float)ispc)); goutbins[i] = sqrtf( (float)mux )/65536.0; Calculate 197 by uint32_t rmux = ( (isps>>16) * (isps>>16)) + ((ispc>>16) * (ispc>>16));

bbkiwi avatar Jul 04 '19 06:07 bbkiwi

See #93

bbkiwi avatar Jul 06 '19 02:07 bbkiwi