diff --git a/poincare/src/division.cpp b/poincare/src/division.cpp index 20e39753c..68fd68a42 100644 --- a/poincare/src/division.cpp +++ b/poincare/src/division.cpp @@ -23,7 +23,7 @@ Expression * Division::clone() const { } Expression * Division::shallowSimplify(Context& context, AngleUnit angleUnit) { - Power * p = new Power(operand(1), new Rational(Integer(-1)), false); + Power * p = new Power(operand(1), new Rational(-1), false); Multiplication * m = new Multiplication(operand(0), p, false); p->deepSimplify(context, angleUnit); detachOperands(); @@ -57,14 +57,14 @@ Expression * Division::shallowBeautify(Context & context, AngleUnit angleUnit) { return replaceWith(o, true); } else { assert(operandIndex == 1); - replaceOperand((Expression *)cos->parent(), new Rational(Integer(-1)), true); + replaceOperand((Expression *)cos->parent(), new Rational(-1), true); } } else { if (operandIndex == 0) { return replaceWith(editableOperand(0), true); } else { assert(operandIndex == 1); - replaceOperand(cos, new Rational(Integer(1)), true); + replaceOperand(cos, new Rational(1), true); } } k++; diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index 1d96f03d5..7d07d4f83 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -48,7 +48,7 @@ Expression * Logarithm::shallowSimplify(Context& context, AngleUnit angleUnit) { } // log(1) = 0; if (r->isOne()) { - return replaceWith(new Rational(Integer(0)), true); + return replaceWith(new Rational(0), true); } Expression * n = splitInteger(r->numerator(), false, context, angleUnit); Expression * d = splitInteger(r->denominator(), true, context, angleUnit); @@ -63,7 +63,7 @@ Expression * Logarithm::splitInteger(Integer i, bool isDenominator, Context & co assert(!i.isZero()); assert(!i.isNegative()); if (i.isOne()) { - return new Rational(Integer(0)); + return new Rational(0); } assert(!i.isOne()); if (Arithmetic::k_primorial32.isLowerThan(i)) { @@ -73,7 +73,7 @@ Expression * Logarithm::splitInteger(Integer i, bool isDenominator, Context & co if (!isDenominator) { return e; } - Multiplication * m = new Multiplication(new Rational(Integer(-1)), e, false); + Multiplication * m = new Multiplication(new Rational(-1), e, false); return m; } Integer factors[Arithmetic::k_maxNumberOfPrimeFactors]; diff --git a/poincare/src/multiplication.cpp b/poincare/src/multiplication.cpp index 60b6b390f..fe0dadfa4 100644 --- a/poincare/src/multiplication.cpp +++ b/poincare/src/multiplication.cpp @@ -115,7 +115,7 @@ Expression * Multiplication::shallowSimplify(Context& context, AngleUnit angleUn mergeOperands(static_cast(o)); index = 0; } else if (o->type() == Type::Rational && static_cast(o)->isZero()) { - return replaceWith(new Rational(Integer(0)), true); + return replaceWith(new Rational(0), true); } } factorize(context, angleUnit); @@ -273,7 +273,7 @@ Expression * Multiplication::distributeOnOperandAtIndex(int i, Context & context } const Expression * Multiplication::CreateExponent(Expression * e) { - Expression * n = e->type() == Type::Power ? e->operand(1)->clone() : new Rational(Integer(1)); + Expression * n = e->type() == Type::Power ? e->operand(1)->clone() : new Rational(1); return n; } @@ -472,7 +472,7 @@ Expression * Multiplication::mergeNegativePower(Context & context, AngleUnit ang if (m->numberOfOperands() == 0) { return this; } - Power * p = new Power(m, new Rational(Integer(-1)), false); + Power * p = new Power(m, new Rational(-1), false); m->sortOperands(SimplificationOrder); m->squashUnaryHierarchy(); const Expression * multOperand[1] = {p}; diff --git a/poincare/src/nth_root.cpp b/poincare/src/nth_root.cpp index 464d72119..90ecec928 100644 --- a/poincare/src/nth_root.cpp +++ b/poincare/src/nth_root.cpp @@ -20,7 +20,7 @@ Expression * NthRoot::clone() const { } Expression * NthRoot::shallowSimplify(Context& context, AngleUnit angleUnit) { - Power * invIndex = new Power(operand(1), new Rational(Integer(-1)), false); + Power * invIndex = new Power(operand(1), new Rational(-1), false); Power * p = new Power(operand(0), invIndex, false); invIndex->shallowSimplify(context, angleUnit); detachOperands(); diff --git a/poincare/src/opposite.cpp b/poincare/src/opposite.cpp index e3439a00d..c6eb06866 100644 --- a/poincare/src/opposite.cpp +++ b/poincare/src/opposite.cpp @@ -31,7 +31,7 @@ Complex Opposite::compute(const Complex c, AngleUnit angleUnit) { Expression * Opposite::shallowSimplify(Context& context, AngleUnit angleUnit) { const Expression * op = operand(0); detachOperand(op); - Multiplication * m = new Multiplication(new Rational(Integer(-1)), op, false); + Multiplication * m = new Multiplication(new Rational(-1), op, false); replaceWith(m, true); return m->shallowSimplify(context, angleUnit); } diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 971a3740b..20d6419a8 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -139,7 +139,7 @@ Expression * Power::shallowSimplify(Context& context, AngleUnit angleUnit) { const Rational * b = static_cast(operand(1)); // x^0 if (b->isZero()) { - return replaceWith(new Rational(Integer(1)), true); + return replaceWith(new Rational(1), true); } // x^1 if (b->isOne()) { @@ -151,7 +151,7 @@ Expression * Power::shallowSimplify(Context& context, AngleUnit angleUnit) { // 0^x if (a->isZero()) { if (operand(1)->sign() == Sign::Positive) { - return replaceWith(new Rational(Integer(0)), true); + return replaceWith(new Rational(0), true); } if (operand(1)->sign() == Sign::Negative) { return replaceWith(new Undefined(), true); @@ -159,7 +159,7 @@ Expression * Power::shallowSimplify(Context& context, AngleUnit angleUnit) { } // 1^x if (a->isOne()) { - return replaceWith(new Rational(Integer(1)), true); + return replaceWith(new Rational(1), true); } // p^q with p, q rationals if (operand(1)->type() == Type::Rational) { @@ -189,7 +189,7 @@ Expression * Power::shallowSimplify(Context& context, AngleUnit angleUnit) { Expression * rCopy = r->clone(); Expression * factor = m->editableOperand(i); if (factor->sign() == Sign::Negative) { - m->replaceOperand(factor, new Rational(Integer(-1)), false); + m->replaceOperand(factor, new Rational(-1), false); factor->setSign(Sign::Positive, context, angleUnit); } else { m->removeOperand(factor, false); @@ -267,7 +267,7 @@ Expression * Power::CreateSimplifiedIntegerRationalPower(Integer i, Rational * r assert(!i.isZero()); assert(r->sign() == Sign::Positive); if (i.isOne()) { - return new Rational(Integer(1)); + return new Rational(1); } if (Arithmetic::k_primorial32.isLowerThan(i)) { r->setSign(isDenominator ? Sign::Negative : Sign::Positive); @@ -318,7 +318,7 @@ Expression * Power::shallowBeautify(Context& context, AngleUnit angleUnit) { // X^-y -> 1/(X->shallowBeautify)^y if (operand(1)->sign() == Sign::Negative) { Expression * p = cloneDenominator(context, angleUnit); - Division * d = new Division(new Rational(Integer(1)), p, false); + Division * d = new Division(new Rational(1), p, false); p->shallowSimplify(context, angleUnit); replaceWith(d, true); return d->shallowBeautify(context, angleUnit); diff --git a/poincare/src/subtraction.cpp b/poincare/src/subtraction.cpp index 7975ddabf..33a1b2dd0 100644 --- a/poincare/src/subtraction.cpp +++ b/poincare/src/subtraction.cpp @@ -29,7 +29,7 @@ Complex Subtraction::compute(const Complex c, const Complex d) { } Expression * Subtraction::shallowSimplify(Context& context, AngleUnit angleUnit) { - Multiplication * m = new Multiplication(new Rational(Integer(-1)), operand(1), false); + Multiplication * m = new Multiplication(new Rational(-1), operand(1), false); Addition * a = new Addition(operand(0), m, false); m->shallowSimplify(context, angleUnit); detachOperands(); diff --git a/poincare/src/trigonometry.cpp b/poincare/src/trigonometry.cpp index 2abbd20d9..643ba0d17 100644 --- a/poincare/src/trigonometry.cpp +++ b/poincare/src/trigonometry.cpp @@ -35,7 +35,7 @@ Expression * Trigonometry::shallowSimplifyDirectFunction(Expression * e, Context if (e->type() == Expression::Type::Cosine) { return e->shallowSimplify(context, angleUnit); } else { - Multiplication * m = new Multiplication(new Rational(Integer(-1)), e->clone(), false); + Multiplication * m = new Multiplication(new Rational(-1), e->clone(), false); m->editableOperand(1)->shallowSimplify(context, angleUnit); return e->replaceWith(m, true)->shallowSimplify(context, angleUnit); } @@ -64,7 +64,7 @@ Expression * Trigonometry::shallowSimplifyDirectFunction(Expression * e, Context unaryCoefficient *= -1; } Expression * simplifiedCosine = e->shallowSimplify(context, angleUnit); // recursive - Multiplication * m = new Multiplication(new Rational(Integer(unaryCoefficient)), simplifiedCosine->clone(), false); + Multiplication * m = new Multiplication(new Rational(unaryCoefficient), simplifiedCosine->clone(), false); return simplifiedCosine->replaceWith(m, true)->shallowSimplify(context, angleUnit); } assert(r->sign() == Expression::Sign::Positive); @@ -121,12 +121,12 @@ Expression * Trigonometry::shallowSimplifyInverseFunction(Expression * e, Contex op->shallowSimplify(context, angleUnit); } if (e->type() == Expression::Type::ArcCosine) { - Expression * pi = angleUnit == Expression::AngleUnit::Radian ? static_cast(new Symbol(Ion::Charset::SmallPi)) : static_cast(new Rational(Integer(180))); + Expression * pi = angleUnit == Expression::AngleUnit::Radian ? static_cast(new Symbol(Ion::Charset::SmallPi)) : static_cast(new Rational(180)); Subtraction * s = new Subtraction(pi, e->clone(), false); s->editableOperand(1)->shallowSimplify(context, angleUnit); return e->replaceWith(s, true)->shallowSimplify(context, angleUnit); } else { - Multiplication * m = new Multiplication(new Rational(Integer(-1)), e->clone(), false); + Multiplication * m = new Multiplication(new Rational(-1), e->clone(), false); m->editableOperand(1)->shallowSimplify(context, angleUnit); return e->replaceWith(m, true)->shallowSimplify(context, angleUnit); }