diff --git a/poincare/include/poincare/multiplication.h b/poincare/include/poincare/multiplication.h index e3b2c1353..8b945206c 100644 --- a/poincare/include/poincare/multiplication.h +++ b/poincare/include/poincare/multiplication.h @@ -83,7 +83,7 @@ public: addChildAtIndexInPlace(e1, 0, numberOfChildren()); } Multiplication(Expression e1, Expression e2, Expression e3) : Multiplication(e2, e3) { - addChildAtIndexInPlace(e3, 0, numberOfChildren()); + addChildAtIndexInPlace(e1, 0, numberOfChildren()); } // Expression diff --git a/poincare/src/arithmetic.cpp b/poincare/src/arithmetic.cpp index 5c838b9a1..47d27076d 100644 --- a/poincare/src/arithmetic.cpp +++ b/poincare/src/arithmetic.cpp @@ -41,9 +41,9 @@ int primeFactors[Arithmetic::k_numberOfPrimeFactors] = {2, 3, 5, 7, 11, 13, 17, // we can go to 7907*7907 = 62 520 649 void Arithmetic::PrimeFactorization(const Integer n, Integer outputFactors[], Integer outputCoefficients[], int outputLength) { + outputCoefficients[0] = -1; if (n.isAllocationFailure()) { /* Special case 0: Allocation failure. */ - outputCoefficients[0] = -1; return; } @@ -63,7 +63,6 @@ void Arithmetic::PrimeFactorization(const Integer n, Integer outputFactors[], In /* Special case 1: We do not want to break i in prime factor because it * might take too many factors... More than k_maxNumberOfPrimeFactors. * outputCoefficients[0] is set to -1 to indicate a special case. */ - outputCoefficients[0] = -1; return; } for (int index = 0; index < outputLength; index++) { diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 888491ad9..3892a741f 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -2,8 +2,8 @@ #include #include -//#include -//#include +#include +#include #include #include //#include @@ -12,7 +12,7 @@ #include #include //#include -//#include +#include #include #include #include @@ -395,16 +395,11 @@ Expression Power::shallowReduce(Context& context, Preferences::AngleUnit angleUn const Expression pi = m.childAtIndex(m.numberOfChildren()-1); m.replaceChildAtIndexInPlace(numberOfChildren()-1, Rational(180)); } -#if 0 Expression reducedM = m.shallowReduce(context, angleUnit); - Cosine cos = Cosine(reducedM).shallowReduce(context, angleUnit); + Expression cos = Cosine(reducedM).shallowReduce(context, angleUnit); Expression sinPart = Sine(reducedM).shallowReduce(context, angleUnit); sinPart = Multiplication(sinPart, i).shallowReduce(context, angleUnit); return Addition(cos, sinPart).shallowReduce(context, angleUnit); -#else - // TODO remove if 0 once we have cos - return Rational(1); -#endif } // x^log(y,x)->y if y > 0 if (childAtIndex(1).type() == ExpressionNode::Type::Logarithm) { @@ -514,10 +509,9 @@ Expression Power::shallowReduce(Context& context, Preferences::AngleUnit angleUn /* The multinome (a0+a2+...+a(m-1))^n has BinomialCoefficient(n+m-1,n) terms; * we expand the multinome only when the number of terms in the resulting * sum has less than k_maxNumberOfTermsInExpandedMultinome terms. */ - //TODO Decomment when BinomialCoefficient available - /*if (k_maxNumberOfTermsInExpandedMultinome < BinomialCoefficient::compute(static_cast(clippedN), static_cast(clippedN+m-1))) { + if (k_maxNumberOfTermsInExpandedMultinome < BinomialCoefficientNode::compute(static_cast(clippedN), static_cast(clippedN+m-1))) { return *this; - }*/ + } Expression result = childAtIndex(0); Expression a = result;