Added Fast Inverse Square Root#11054
Conversation
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
maths/fast_inverse_sqrt.py
Outdated
| >>> fastInvSqrt(10) | ||
| 0.3156857923527257 | ||
|
|
||
| >>> fastInvSqrt(4) | ||
| 0.49915357479239103 |
There was a problem hiding this comment.
| >>> fastInvSqrt(10) | |
| 0.3156857923527257 | |
| >>> fastInvSqrt(4) | |
| 0.49915357479239103 | |
| >>> fast_inverse_sqrt(10) | |
| 0.3156857923527257 | |
| >>> fast_inverse_sqrt(4) | |
| 0.49915357479239103 | |
| >>> fast_inverse_sqrt(0) | |
| ??? | |
| >>> fast_inverse_sqrt(-4) | |
| ??? | |
| >>> fast_inverse_sqrt(4.1) | |
| ??? | |
| >>> from math import sqrt | |
| >>> all(fast_inverse_sqrt(i) == sqrt(i) for i in range(-10, 10)) | |
| True |
cclauss
left a comment
There was a problem hiding this comment.
Add some doctests that break things.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
maths/fast_inverse_sqrt.py
Outdated
| import struct | ||
|
|
||
|
|
||
| def fast_inverse_sqrt(x: float) -> float: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: x
for more information, see https://pre-commit.ci
|
The test may/may not fail due to the approximation of answer, which is the essence of this method. Pls review for any additional change. |
|
As discussed in CONTRIBUTING.md you can run the tests on your own computer with: |

Describe your change:
Checklist: