diff --git a/cmake/gitect.cmake b/cmake/gitect.cmake index cae90a0b1..48bcc6917 100644 --- a/cmake/gitect.cmake +++ b/cmake/gitect.cmake @@ -25,6 +25,7 @@ if(GIT_EXECUTABLE) add_custom_target(rebase-main WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} pull --rebase --autostash origin main + COMMAND ${GIT_EXECUTABLE} fetch --all ) set_target_properties(rebase-main PROPERTIES EXCLUDE_FROM_ALL 1 diff --git a/omnn/math/Product.cpp b/omnn/math/Product.cpp index 6e5536712..95365013f 100644 --- a/omnn/math/Product.cpp +++ b/omnn/math/Product.cpp @@ -962,7 +962,7 @@ namespace math { return *this; } else if (v.IsSimple() ) { - if (v == 1_v) { + if (v == constants::one) { return *this; } else if (v.IsConstant()) { auto it = std::find(begin(), end(), v); @@ -1145,10 +1145,10 @@ namespace math { same && it1 != e1 && it2 != e2; ++it1, ++it2) { - if(it1->Same(1_v)){ + if(it1->Same(constants::one)){ ++it1; } - if(it2->Same(1_v)){ + if(it2->Same(constants::one)){ ++it2; } @@ -1190,23 +1190,37 @@ namespace math { same = c1.rbegin()->operator==(v); } else if (members.empty()) { same = v == 1; - } else if (v.IsExponentiation() && Has(v)) { - auto n = members.size(); - same = n == 1; - if (!same) { - auto& e = v.as(); - same = e.IsMultiSign() && n == 2 && Has(constants::minus_1); - if (!same && Has(constants::i)) { - auto& ee = e.getExponentiation(); - if (ee.IsFraction()) { - auto& eef = ee.as(); - auto& eefdn = eef.getDenominator(); - same = eefdn >= 4 || eefdn <= -4; - } else { - LOG_AND_IMPLEMENT("Examine new multisign form: " << *this << " == " << e); + } else if (v.IsExponentiation()) { + if (Has(v)) { + auto sz1 = c1.size(); + same = sz1 == 1; + if (!same) { + auto& e = v.as(); + same = e.IsMultiSign() && sz1 == 2 && Has(constants::minus_1); + if (!same && Has(constants::i)) { + auto& ee = e.getExponentiation(); + if (ee.IsFraction()) { + auto& eef = ee.as(); + auto& eefdn = eef.getDenominator(); + same = eefdn >= 4 || eefdn <= -4; + } else { + LOG_AND_IMPLEMENT("Examine new multisign form: " << *this << " == " << e); + } } } } + else { + auto& e = v.as(); + auto& ee = e.getExponentiation(); + same = ee.IsSimple() && ee < constants::zero + && operator==(e.getBase().Reciprocal() ^ -ee); + } + } else if (v.IsProduct() + && IsMultival() == YesNoMaybe::Yes + && v.IsMultival() == YesNoMaybe::Yes) + { + // TODO: Check if it has same multival exponentiation and different sign or i in coefficient + //LOG_AND_IMPLEMENT("Check if it has same multival exponentiation and different sign or i in coefficient: " << *this << " == " << v); } return same; } @@ -1249,7 +1263,7 @@ namespace math { auto it = coVa.find(va); if (it != coVa.end()) { if (it->second < 0) { - s = ((*this / (it->first ^ it->second)) / augmentation) ^ (1_v / -it->second); + s = ((*this / (it->first ^ it->second)) / augmentation) ^ (-it->second).Reciprocal(); } else { diff --git a/omnn/math/test/Fraction_test.cpp b/omnn/math/test/Fraction_test.cpp index f5cadc840..0729a2426 100644 --- a/omnn/math/test/Fraction_test.cpp +++ b/omnn/math/test/Fraction_test.cpp @@ -83,14 +83,12 @@ BOOST_AUTO_TEST_CASE(FractionSimplification_tests ){ auto _1 = (25_v / 5) ^ Fraction{constants::minus_1,constants::two}; auto _2 = (1_v / 5)*(1_v^(1_v/2)); - auto c = _1 == _2; - BOOST_TEST(c); + BOOST_TEST(_1 == _2); DECL_VA(x); _1 =(-1_v)^x; _2 = (-1_v)^((1_v/2)*x + _1/4 + ((-1_v)/4)); - c = _1 != _2; - BOOST_TEST(c); + BOOST_TEST(_1 != _2); } BOOST_AUTO_TEST_CASE(Fraction_optimization_no_hang_test