diff --git a/poincare/include/poincare/arithmetic.h b/poincare/include/poincare/arithmetic.h index 298360796..1d5c95adb 100644 --- a/poincare/include/poincare/arithmetic.h +++ b/poincare/include/poincare/arithmetic.h @@ -11,12 +11,11 @@ public: static void PrimeFactorization(const Integer * i, Integer * outputFactors, Integer * outputCoefficients, int outputLength); constexpr static int k_numberOfPrimeFactors = 1000; constexpr static int k_maxNumberOfPrimeFactors = 32; - static const Integer k_biggestPrimeFactorizedInteger; static const Integer k_primorial32; private: /* When decomposing an integer into primes factors, we look for its prime - * factors among integer from 2 to 100000000. */ - constexpr static int k_biggestPrimeFactor = 1E8; + * factors among integer from 2 to 10000. */ + constexpr static int k_biggestPrimeFactor = 10000; }; } diff --git a/poincare/src/arithmetic.cpp b/poincare/src/arithmetic.cpp index 47c44eefe..161db6938 100644 --- a/poincare/src/arithmetic.cpp +++ b/poincare/src/arithmetic.cpp @@ -3,7 +3,6 @@ namespace Poincare { -const Integer Arithmetic::k_biggestPrimeFactorizedInteger("1000000000000"); // 1E12 const Integer Arithmetic::k_primorial32("525896479052627740771371797072411912900610967452630"); Integer Arithmetic::LCM(const Integer * a, const Integer * b) { diff --git a/poincare/src/expression_debug.cpp b/poincare/src/expression_debug.cpp index 956522d00..910aa94cd 100644 --- a/poincare/src/expression_debug.cpp +++ b/poincare/src/expression_debug.cpp @@ -235,7 +235,7 @@ void print_prime_factorization(Integer * outputFactors, Integer * outputCoeffici std::cout << outputFactors[index].approximate(); std::cout << "^"; std::cout << outputCoefficients[index].approximate(); - std::cout << "+"; + std::cout << "*"; } std::cout <<" "<< std::endl; } diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index ff17271ad..43cea1765 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -148,10 +148,9 @@ Expression * Logarithm::splitInteger(Integer i, bool isDenominator, Context & co return new Rational(0); } assert(!i.isOne()); - if (Arithmetic::k_primorial32.isLowerThan(i) || Arithmetic::k_biggestPrimeFactorizedInteger.isLowerThan(i)) { - /* We do not want to break i in prime factor because - * - either it might be take too many factors... More than k_maxNumberOfPrimeFactors. - * - Or, it might takes too much time */ + if (Arithmetic::k_primorial32.isLowerThan(i)) { + /* We do not want to break i in prime factor because it might be take too + * many factors... More than k_maxNumberOfPrimeFactors. */ Expression * e = clone(); e->replaceOperand(e->operand(0), new Rational(i), true); if (!isDenominator) { diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index b5a6ab028..a81e2520a 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -426,10 +426,10 @@ Expression * Power::CreateSimplifiedIntegerRationalPower(Integer i, Rational * r } Integer absI = i; absI.setNegative(false); - if (Arithmetic::k_primorial32.isLowerThan(absI) || Arithmetic::k_biggestPrimeFactorizedInteger.isLowerThan(absI)) { + if (Arithmetic::k_primorial32.isLowerThan(absI)) { r->setSign(isDenominator ? Sign::Negative : Sign::Positive); /* We do not want to break i in prime factor because it might be take too - * many factors... More than k_maxNumberOfPrimeFactors; or too much time!*/ + * many factors... More than k_maxNumberOfPrimeFactors. */ return new Power(new Rational(i), r->clone(), false); } Integer factors[Arithmetic::k_maxNumberOfPrimeFactors]; diff --git a/poincare/test/arithmetic.cpp b/poincare/test/arithmetic.cpp index accd9529e..841bd6a10 100644 --- a/poincare/test/arithmetic.cpp +++ b/poincare/test/arithmetic.cpp @@ -83,6 +83,6 @@ QUIZ_CASE(poincare_arithmetic) { int coefficients2[3] = {2,4,2}; assert_prime_factorization_equals_to(Integer(122500), factors2, coefficients2, 3); int factors3[8] = {3,7,11, 13, 19, 3607, 3803, 52579}; - int coefficients3[8] = {4,2,2,2,2,2,2,2}; - assert_prime_factorization_equals_to(Integer("15241578780673678515622620750190521"), factors3, coefficients3, 8); + int coefficients3[8] = {4,2,2,2,2,2,2,1}; + assert_prime_factorization_equals_to(Integer("289879586539753105148873518899"), factors3, coefficients3, 8); }