-
Notifications
You must be signed in to change notification settings - Fork 349
[RFC]Math: Trignometry: Added cordic cos function #4053
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
Conversation
458b5f3 to
81a0484
Compare
cujomalainey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address checkpatch comments, also im not sure if Johny has mentioned but we are seeing a performance regression with the new sign function that i think we need to figure out before we land this
It seems exp_fixed function is consuming most of the computation time in 3 band DRC. CORDIC SINE when compared with old sine performs better #3990 (comment) |
|
Isn't it literally possible to do cos(x) = sin(pi/2 - x)? |
Yes, this is done by the during coordinate check pi/2. Variable xn and b_yn share
Yes , this is done during co-ordinate check. th_rad_fxp = sign * b_yn; for sine and th_rad_fxp = sign * xn for cosine. |
Guess that's a lot of common code then, we can factor out the common part into a single function to avoid code duplication. |
Yes. That's correct, will make common function with a separator for sine and cosine. |
6042ff3 to
d5d1363
Compare
d5d1363 to
8e5ff14
Compare
2a3b52b to
25395e0
Compare
paulstelian97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume by now the mathematical kinks of the function itself are solved (and thus we now know it's correct); the code itself looks good.
3bf1747 to
e1b3ddd
Compare
e1b3ddd to
cbd20c9
Compare
cbd20c9 to
324697a
Compare
Cordic sin cos input value range is [-2*pi to 2*pi] and output range is [-1 to +1] This is common function to calculate trignometric sine and cosine using separate lookup table size for speeds and accuracy calculation. For 32bit sine and cosine Error (max = 0.000000011175871), THD+N = -170.152933 For 16bit sine and cosine Error (max = 0.000061), THD+N = -91.518584 Signed-off-by: ShriramShastry <malladi.sastry@intel.com>
324697a to
d5e2273
Compare
singalsu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks Sriram!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approve, previous got cleared.
| inline int32_t drc_sin_fixed(int32_t x) | ||
| { | ||
| const int32_t PI_OVER_TWO = Q_CONVERT_FLOAT(1.57079632679489661923f, 30); | ||
| const int32_t PI_OVER_TWO = Q_CONVERT_FLOAT(1.57079632679489661923, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will only be inline if they are used in the same C file. @ShriramShastry can you do an incremental update that takes all these small inline maths function and moves them to the maths headers (and changes them to static inline).
This will save us a function call on all our small maths ops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Liam, Seppo. I have a new PR #4218 to include your inputs.
| */ | ||
| inline int32_t sin_fixed_32b(int32_t th_rad_fxp) | ||
| { | ||
| int32_t sign; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. here, as this will generate 2 function calls when used outside of trig.c i.e.
- sin_fixed_32b()
- cordic_sin_cos()
We want to eliminate call 1.
Same for all the other small maths functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ange is [-2pi to 2pi] and output range is [-1 to +1] Mean and maximum value for the difference between floating to fixed point output is 3.2136e-09 and 0.0000000596
Signed-off-by: ShriramShastry malladi.sastry@intel.com