From d0f075108e33626f943961d3d455397aa5807a1e Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 11 Mar 2018 15:21:36 +1100 Subject: [PATCH] maths: remove gcd in favour of the std implementation --- maths.hpp | 19 ------------------- rand/lcg.cpp | 2 +- rational.cpp | 2 +- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/maths.hpp b/maths.hpp index cd030e00..340d6851 100644 --- a/maths.hpp +++ b/maths.hpp @@ -416,25 +416,6 @@ namespace util { /////////////////////////////////////////////////////////////////////////////// // factorisation template - constexpr T - gcd (T a, T b) - { - assert (a); - assert (b); - - while (a != b) { - if (a > b) - a -= b; - else if (b > a) - b -= a; - } - - return a; - } - - - //----------------------------------------------------------------------------- - template const T& identity (const T& t) { diff --git a/rand/lcg.cpp b/rand/lcg.cpp index 893c59a6..c531c301 100644 --- a/rand/lcg.cpp +++ b/rand/lcg.cpp @@ -28,7 +28,7 @@ bool is_coprime (T M, T C) { if (M == 0) return true; - if (util::gcd (M, C) == 1u) + if (std::gcd (M, C) == 1u) return true; return false; } diff --git a/rational.cpp b/rational.cpp index b64ff473..f201a4a1 100644 --- a/rational.cpp +++ b/rational.cpp @@ -109,7 +109,7 @@ template rational rational::reduced (void) const { - auto x = gcd (abs (n), abs (d)); + auto x = std::gcd (abs (n), abs (d)); return { n / x, d / x }; }