TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of the inverse square root Root. More...
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <limits>
Go to the source code of this file.
Functions | |
template<typename T = double, char iterations = 2> | |
T | Fast_InvSqrt (T x) |
for std::sqrt | |
template<typename T = double> | |
T | Standard_InvSqrt (T number) |
This is the function that calculates the fast inverse square root. The following code is the fast inverse square root with standard lib (cmath) More information can be found at LinkedIn | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. | |
Implementation of the inverse square root Root.
Two implementation to calculate inverse inverse root, from Quake III Arena (C++ version) and with a standard library (cmath
). This algorithm is used to calculate shadows in Quake III Arena.
Definition in file inv_sqrt.cpp.
|
inline |
for std::sqrt
for assert for IO operations for numeric_limits
This is the function that calculates the fast inverse square root. The following code is the fast inverse square root implementation from Quake III Arena (Adapted for C++). More information can be found at Wikipedia
T | floating type |
iterations | inverse square root, the greater the number of iterations, the more exact the result will be (1 or 2). |
x | value to calculate |
Definition at line 28 of file inv_sqrt.cpp.
int main | ( | void | ) |
Main function.
Definition at line 87 of file inv_sqrt.cpp.
T Standard_InvSqrt | ( | T | number | ) |
This is the function that calculates the fast inverse square root. The following code is the fast inverse square root with standard lib (cmath) More information can be found at LinkedIn
T | floating type |
number | value to calculate |
Definition at line 59 of file inv_sqrt.cpp.
|
static |
Self-test implementations.
Definition at line 68 of file inv_sqrt.cpp.