ARM-software / CMSIS-DSP

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A
https://arm-software.github.io/CMSIS-DSP
Apache License 2.0
454 stars 122 forks source link

Value range of arm_atan2_* #156

Closed marcluque closed 4 months ago

marcluque commented 4 months ago

I was going over the atan2 documentation, but couldn't find any indication of the radian range that is used. Can somebody help me determine this? I tried going over the code, but it doesn't seem obvious to me what value range can be expected. I'm thinking that it is (-Pi, Pi], but it would be great to have that confirmed. Would also be great if the documentation for atan2 could be updated with the expected range.

While going over the atan2 code, I noticed that the implementation slightly deviates from an exemplary definition given on Wikipedia. In particular, this line does not seem to be "correct", since the case is never possible for q15_t. It seems like this code might have been taken from the floating point implementation where this distinction makes sense. Another thing hinting at this is this line.

christophe0606 commented 4 months ago

@marcluque You're right. This function needs a bit of cleaning. The tests are comparing it with the Numpy arctan2 so the output should be between -pi and pi.

marcluque commented 4 months ago

@christophe0606 thank you for checking and giving the confirmation!

christophe0606 commented 4 months ago

Documentation improved.