-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arm_cos_f32 with around -pi/2 #267
Comments
Hi @idt12312, thanks for letting us know. Is it feasible to to ask you for some more details to reproduce the problem and validate a fix? I guess you call Best, |
Hi @JonatanAntoni ,
This means as follows. uint32_t x_bin = 0xbfc90fdc;
float *x = (float*)&x_bin; // *x is -pi/2 in float
float cos_result = arm_cos_f32(*x); This cos_result should be about 0.0 (=cos(-pi/2)), but this is over 1.0. |
Hi, |
@llefaucheur |
You are true the comments in the code (not exactly reproduced in the API) are not as strong as it should (https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/DSP/Source/FastMathFunctions/arm_cos_f32.c#L80 : "Scale the input to [0 1] range from [0 2*PI] " without telling to avoid data out of this range. We will correct this quickly. |
@llefaucheur @JonatanAntoni |
I don't think this makes sense. The test data, and the examples include plenty of negative numbers.
I think this is exactly right. The special case implemented in arm_sin_f32 should be carried over to arm_cos_f32. We can see that in the top of the test data there is already a special entry of -1.5E-07, seemingly to verify the arm_sin_f32. We should similarly add -1.5707965 that @idt12312 identified, to check correct operation of arm_cos_f32. EDIT: |
@madcowswe Thank you for letting me know. |
Problem
I found a result value from arm_cos_f32 is wrong in a particular situation.
The problem occurred when I call the function with a parameter around -pi/2.
Concretely, when the parameter is 0xbfc90fdc or 0xbfc90fdd (this value means -pi/2 in 32bit float), this problem occurred.
Possible Cause
I think this problem is related to a past bug of arm_sin_f32.
According to the following change log, a bug of arm_sin_f32 was fixed at Version 1.4.10.
http://www.keil.com/pack/doc/CMSIS/DSP/html/ChangeLog_pg.html
I think added lines to fix this bug are here.
CMSIS_5/CMSIS/DSP/Source/FastMathFunctions/arm_sin_f32.c
Line 81 in d05a7dc
Although the implementation of arm_cos_f32 is very similar to arm_sin_f32 and a same bug can occur in arm_sin_f32 cos, changes have been made only for arm_sin_f32.
The text was updated successfully, but these errors were encountered: