|
|
6c001bf |
From 9f68be99919871283238e4a12940d9581d724af2 Mon Sep 17 00:00:00 2001
|
|
|
6c001bf |
From: David Ostrovsky <david@ostrovsky.org>
|
|
|
6c001bf |
Date: Thu, 4 May 2017 19:14:13 +0200
|
|
|
6c001bf |
Subject: [PATCH] Use gcd from boost::math::gcd
|
|
|
6c001bf |
|
|
|
6c001bf |
According to the documentation "Run-time GCD & LCM Determination": [1],
|
|
|
6c001bf |
gcd should be consumed from boost::math::gcd.
|
|
|
6c001bf |
|
|
|
6c001bf |
[1] <http://www.boost.org/doc/libs/1_64_0/libs/math/doc/html/math_toolkit/run_time.html>
|
|
|
6c001bf |
|
|
|
6c001bf |
Change-Id: I026a4e8ead75399765eb73fa5434a57958676383
|
|
|
6c001bf |
Reviewed-on: https://gerrit.libreoffice.org/37260
|
|
|
6c001bf |
Tested-by: Jenkins <ci@libreoffice.org>
|
|
|
6c001bf |
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
|
|
|
6c001bf |
---
|
|
|
6c001bf |
tools/source/generic/fract.cxx | 5 +++--
|
|
|
6c001bf |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
6c001bf |
|
|
|
6c001bf |
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
|
|
|
6c001bf |
index bc9bef467e86..afcb2e60ba42 100644
|
|
|
6c001bf |
--- a/tools/source/generic/fract.cxx
|
|
|
6c001bf |
+++ b/tools/source/generic/fract.cxx
|
|
|
6c001bf |
@@ -30,6 +30,7 @@
|
|
|
6c001bf |
#include <algorithm>
|
|
|
6c001bf |
#include <cmath>
|
|
|
6c001bf |
|
|
|
6c001bf |
+#include <boost/math/common_factor_rt.hpp>
|
|
|
6c001bf |
#include <boost/rational.hpp>
|
|
|
6c001bf |
|
|
|
6c001bf |
template<typename T>
|
|
|
6c001bf |
@@ -180,8 +181,8 @@ namespace
|
|
|
6c001bf |
T den = r.denominator();
|
|
|
6c001bf |
|
|
|
6c001bf |
// Avoid overflow and preserve normalization
|
|
|
6c001bf |
- T gcd1 = boost::integer::gcd(i.numerator(), den);
|
|
|
6c001bf |
- T gcd2 = boost::integer::gcd(num, i.denominator());
|
|
|
6c001bf |
+ T gcd1 = boost::math::gcd(i.numerator(), den);
|
|
|
6c001bf |
+ T gcd2 = boost::math::gcd(num, i.denominator());
|
|
|
6c001bf |
|
|
|
6c001bf |
bool fail = false;
|
|
|
6c001bf |
fail |= o3tl::checked_multiply(i.numerator() / gcd1, num / gcd2, num);
|
|
|
6c001bf |
--
|
|
|
6c001bf |
2.12.2
|
|
|
6c001bf |
|