Skip to content
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

Use Pythagorean identity to shrink sine table #21

Closed
wants to merge 1 commit into from
Closed

Use Pythagorean identity to shrink sine table #21

wants to merge 1 commit into from

Conversation

ndsl7109256
Copy link
Collaborator

The sine table contribute a large code size. To optimize this, the Pythagorean identity has been applied to minimize the size of sine table. The adjustment decreases code size while preserving the accuracy of sine calculations.

The sine table contribute a large code size. To optimize this, the
Pythagorean identity has been applied to minimize the size of sine
table. The adjustment decreases code size while preserving the accuracy
of sine calculations.
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run clang-format -i to ensure consistent indention.

};

/*
* angles are measured from -2048 .. 2048
*/


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change this line. Minimize the necessary changes.

@jouae
Copy link
Collaborator

jouae commented Jul 27, 2024

@ndsl7109256 Can you briefly explain how the Pythagorean identity can reduce the size of the table, or provide a comment in the code explaining how it works?

And you can use the size command as mentioned in #13 to check how much memory overhead has been reduced compared to the original.

Thanks

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the git commit message. In particular, make it grammatically correct.

As @jouae mentioned, prove that the proposed method is beneficial and maintains the desired precision. You may consider introducing the CORDIC method for sine computation without using expensive lookup tables. Check the following:

@jouae
Copy link
Collaborator

jouae commented Jul 27, 2024

@ndsl7109256
By the way, the __sin_s3() function used in vwifi is a third-order fixed-point approximation of the sine function. However, the reference documentation Another fast fixed-point sine approximation seems to be unavailable now. The principle is similar to the 5th Order Polynomial Fixed-Point Sine Approximation mentioned by @jserv.

For a Chinese explanation of __sin_s3(), you can refer to the document written by @rickywu0421 at 2022q1 vwifi.

@ndsl7109256
Copy link
Collaborator Author

@jserv @jouae Thanks for the advice. I would open another pull request to use third-order approximation to compute sine values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants