Skip to content
Snippets Groups Projects
Commit 4ca856e7 authored by Nicolas Mellado's avatar Nicolas Mellado :speech_balloon:
Browse files

add constexpr sqrt implementation

parent 9ddf2107
No related branches found
No related tags found
No related merge requests found
......@@ -9,12 +9,24 @@
#include <random>
namespace RadiumNBR {
Scalar constexpr sqrtNewtonRaphsonhelper(Scalar x, Scalar curr, Scalar prev)
{
return curr == prev
? curr
: sqrtNewtonRaphsonhelper(x, 0.5_ra * (curr + x / curr), curr);
}
Scalar constexpr ct_sqrt(Scalar x){
return sqrtNewtonRaphsonhelper( x, x, 0_ra );
}
/// Implements the 2D fibonacci sequence
/// (i, N) => [i / phi, i / N]
/// where phi = (1 + sqrt(5)) / 2
class NodeBasedRenderer_LIBRARY_API FibonacciSequence
{
static constexpr Scalar phi = ( 1_ra + std::sqrt( 5_ra ) ) / 2_ra;
static constexpr Scalar phi = ( 1_ra + ct_sqrt( 5_ra ) ) / 2_ra;
int n;
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment