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

feat: add fast trigonometric functions #243

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

Soptq
Copy link
Contributor

@Soptq Soptq commented Jan 17, 2024

This PR adds fast trigonometric functions (sin, cos, tan) to the library. Compared to standard trigonometric functions, fast trigonometric functions are computational and spacial efficient, with minor (acceptable errors).

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

  • Add fast trigonometric functions (sin, cos, tan) to the library
  • All tests are passed

Does this introduce a breaking change?

  • Yes
  • No

Other information

@Soptq Soptq requested a review from 0xLucqs as a code owner January 17, 2024 06:02
src/math/src/trigonometry.cairo Outdated Show resolved Hide resolved
src/math/src/trigonometry.cairo Outdated Show resolved Hide resolved
src/math/src/trigonometry.cairo Outdated Show resolved Hide resolved
@0xLucqs
Copy link
Collaborator

0xLucqs commented Jan 22, 2024

why not i64 everywhere ?

@Soptq
Copy link
Contributor Author

Soptq commented Jan 22, 2024

why not i64 everywhere ?

Thanks @LucasLvy for taking time to review this PR!

It seems that i64 does not implement core::traits::Div and core::traits::Rem, which is crucial for the fast trigonometric algorithm. Consequently, I decided to firstly implement sin(x) for x > 0, and thereby obtaining sin(x), cos(x) and tan(x) for x < 0 and x > 0 using symmetry properties.

@0xLucqs 0xLucqs merged commit 80591b4 into keep-starknet-strange:main Jan 23, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants