4 releases
0.1.3 | May 26, 2022 |
---|---|
0.1.2 | May 23, 2022 |
0.1.1 | May 23, 2022 |
0.1.0 | May 23, 2022 |
#1041 in Math
15KB
74 lines
A simple rust implementation of the Quake III reverse square root alghorithm.
Safety
The main trait implementations are not marked as unsafe. However, given that
std::mem::transmute
is used under the hood undefined behaviour is always a possibility.
The library guarantees, however, that needed conversions are done between equally sized types.
lib.rs
:
quake-inverse-sqrt
This crate implements a trait for all numeric base types to give them the ability to compute their own inverse square root using the infamous Quake III algorithm.
The result is approximated in favour of speed of execution.
Example
let num: f32 = 4.0.fast_inverse_sqrt();
assert!(num > 0.49 && num < 0.51);