From 2486d0e7ebc209f2d6d9d36fa25772e990415bc5 Mon Sep 17 00:00:00 2001 From: Sergii Kryvonos Date: Fri, 20 Dec 2024 19:07:14 +0100 Subject: [PATCH] better coverage for fractions comparison --- omnn/math/Fraction.cpp | 13 ++++++++++--- omnn/math/test/ts.cpp | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/omnn/math/Fraction.cpp b/omnn/math/Fraction.cpp index eb96d72cb7..2443e170e2 100644 --- a/omnn/math/Fraction.cpp +++ b/omnn/math/Fraction.cpp @@ -78,9 +78,16 @@ using namespace omnn::math; auto bothAreRational = (IsRational() && fraction.IsRational()) == YesNoMaybe::Yes; if (bothAreRational) { equal = operator a_rational() == static_cast(fraction); - } else { // TODO: FIXME: both irrationals hangs on macos - //OptimizeOn on; - //equal = numerator() * fraction.denominator() == fraction.numerator() * denominator(); + } else { + if (optimized1) { + equal = operator==(fraction.Optimized(fraction.GetView())); + } else if (optimized2) { + equal = Optimized(GetView()) == fraction; + } else { + auto _1 = Optimized(GetView()); + auto _2 = fraction.Optimized(fraction.GetView()); + equal = _1 == _2; + } } } } diff --git a/omnn/math/test/ts.cpp b/omnn/math/test/ts.cpp index 7cd472e8eb..7cda193001 100644 --- a/omnn/math/test/ts.cpp +++ b/omnn/math/test/ts.cpp @@ -22,7 +22,7 @@ T bits_in_use(T v){ /// Control theory generalization hints are here: finds best moves/goods for single dimension BOOST_AUTO_TEST_CASE(TS_1d) { std::cout << "TS_1d test case - Start" << std::endl; - // System s; + //System s; // s.MakeTotalEqu(true); // y=f(x), where x is code of sequence DECL_VARS(time, price);