mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 14:50:44 +01:00
[poincare] Change name: cloneDenominator->denominator
This commit is contained in:
@@ -154,7 +154,7 @@ public:
|
||||
|
||||
protected:
|
||||
// Private methods used in simplification process
|
||||
/*!*/ virtual Expression cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
/*!*/ virtual Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
/* Hierarchy */
|
||||
ExpressionNode * childAtIndex(int i) const override { return static_cast<ExpressionNode *>(TreeNode::childAtIndex(i)); }
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
void factorizeBase(Expression * e1, Expression * e2, Context & context, Preferences::AngleUnit angleUnit);
|
||||
void factorizeExponent(Expression * e1, Expression * e2, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression * distributeOnOperandAtIndex(int index, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression * cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
Expression * denominator(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
void addMissingFactors(Expression * factor, Context & context, Preferences::AngleUnit angleUnit);
|
||||
void factorizeSineAndCosine(Expression * o1, Expression * o2, Context & context, Preferences::AngleUnit angleUnit);
|
||||
static bool HaveSameNonRationalFactors(const Expression * e1, const Expression * e2);
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
int simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const override;
|
||||
int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override;
|
||||
Expression * simplifyPowerPower(Power * p, Expression * r, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression * cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
Expression * denominator(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
Expression * simplifyPowerMultiplication(Multiplication * m, Expression * r, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression * simplifyRationalRationalPower(Expression * result, Rational * a, Rational * b, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression * removeSquareRootsFromDenominator(Context & context, Preferences::AngleUnit angleUnit);
|
||||
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override;
|
||||
Expression shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
|
||||
Expression cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const override;
|
||||
bool m_negative;
|
||||
size_t m_numberOfDigitsNumerator;
|
||||
size_t m_numberOfDigitsDenominator;
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
/* Simplification */
|
||||
Expression setSign(ExpressionNode::Sign s);
|
||||
Expression shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
Expression cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ Expression * Addition::factorizeOnCommonDenominator(Context & context, Preferenc
|
||||
// Step 1: We want to compute the common denominator, b*d
|
||||
Multiplication * commonDenominator = new Multiplication();
|
||||
for (int i = 0; i < numberOfChildren(); i++) {
|
||||
Expression * denominator = operand(i)->cloneDenominator(context, angleUnit);
|
||||
Expression * denominator = operand(i)->denominator(context, angleUnit);
|
||||
if (denominator) {
|
||||
// Make commonDenominator = LeastCommonMultiple(commonDenominator, denominator);
|
||||
commonDenominator->addMissingFactors(denominator, context, angleUnit);
|
||||
|
||||
@@ -112,7 +112,7 @@ bool ExpressionNode::isOfType(Type * types, int length) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Expression ExpressionNode::cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
Expression ExpressionNode::denominator(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
return Expression(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -612,14 +612,14 @@ Expression * Multiplication::shallowBeautify(Context & context, Preferences::Ang
|
||||
return this;
|
||||
}
|
||||
|
||||
Expression * Multiplication::cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
Expression * Multiplication::denominator(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
// Merge negative power: a*b^-1*c^(-Pi)*d = a*(b*c^Pi)^-1
|
||||
// WARNING: we do not want to change the expression but to create a new one.
|
||||
SimplificationRoot root(clone());
|
||||
Expression * e = ((Multiplication *)root.operand(0))->mergeNegativePower(context, angleUnit);
|
||||
Expression * result = nullptr;
|
||||
if (e->type() == Type::Power) {
|
||||
result = static_cast<Power *>(e)->cloneDenominator(context, angleUnit);
|
||||
result = static_cast<Power *>(e)->denominator(context, angleUnit);
|
||||
} else {
|
||||
assert(e->type() == Type::Multiplication);
|
||||
for (int i = 0; i < e->numberOfChildren(); i++) {
|
||||
|
||||
@@ -668,7 +668,7 @@ Expression * Power::CreateNthRootOfUnity(const Rational r) {
|
||||
Expression Power::shallowBeautify(Context& context, Preferences::AngleUnit angleUnit) {
|
||||
// X^-y -> 1/(X->shallowBeautify)^y
|
||||
if (operand(1)->sign() == Sign::Negative) {
|
||||
Expression * p = cloneDenominator(context, angleUnit);
|
||||
Expression * p = denominator(context, angleUnit);
|
||||
Division * d = new Division(RationalReference(1), p, false);
|
||||
p->shallowReduce(context, angleUnit);
|
||||
replaceWith(d, true);
|
||||
@@ -694,7 +694,7 @@ Expression Power::shallowBeautify(Context& context, Preferences::AngleUnit angle
|
||||
return this;
|
||||
}
|
||||
|
||||
Expression * Power::cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
Expression * Power::denominator(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
if (operand(1)->sign() == Sign::Negative) {
|
||||
Expression * denominator = clone();
|
||||
Expression * newExponent = denominator->editableOperand(1)->setSign(Sign::Positive, context, angleUnit);
|
||||
|
||||
Reference in New Issue
Block a user