mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[poincare] Number::setSign does not need a context or angleUnit
This commit is contained in:
@@ -101,7 +101,7 @@ private:
|
||||
constexpr static int k_maxMantissaLength = 20;
|
||||
DecimalNode * node() const { return static_cast<DecimalNode *>(Number::node()); }
|
||||
Decimal(size_t size, const Integer & m, int e);
|
||||
Expression setSign(ExpressionNode::Sign s, Context * context, Preferences::AngleUnit angleUnit);
|
||||
Expression setSign(ExpressionNode::Sign s);
|
||||
// Simplification
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression shallowBeautify(Context & context, Preferences::AngleUnit angleUnit);
|
||||
|
||||
@@ -46,7 +46,9 @@ public:
|
||||
static Number Power(const Number & i, const Number & j);
|
||||
static int NaturalOrder(const Number & i, const Number & j);
|
||||
|
||||
Number setSign(ExpressionNode::Sign s, Context * context, Preferences::AngleUnit angleUnit) { return Expression::setSign(s, context, angleUnit).convert<Number>(); }
|
||||
/* Number::setSign does not need a context or an angle unit (a number can be
|
||||
* Infinity, Undefined, Float, Decimal, Rational). */
|
||||
Number setSign(ExpressionNode::Sign s) { return Expression::setSign(s, nullptr, Preferences::AngleUnit::Degree).convert<Number>(); }
|
||||
protected:
|
||||
Number() : Expression() {}
|
||||
NumberNode * node() const { return static_cast<NumberNode *>(Expression::node()); }
|
||||
|
||||
@@ -57,7 +57,7 @@ size_t DecimalNode::size() const {
|
||||
}
|
||||
|
||||
Expression DecimalNode::setSign(Sign s, Context * context, Preferences::AngleUnit angleUnit) {
|
||||
return Decimal(this).setSign(s, context, angleUnit);
|
||||
return Decimal(this).setSign(s);
|
||||
}
|
||||
|
||||
int DecimalNode::simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const {
|
||||
@@ -336,7 +336,7 @@ Decimal::Decimal(size_t size, const Integer & m, int e) : Number(TreePool::share
|
||||
node()->setValue(m.digits(), m.numberOfDigits(), e, m.isNegative());
|
||||
}
|
||||
|
||||
Expression Decimal::setSign(ExpressionNode::Sign s, Context * context, Preferences::AngleUnit angleUnit) {
|
||||
Expression Decimal::setSign(ExpressionNode::Sign s) {
|
||||
Decimal result = *this;
|
||||
result.node()->setNegative(s == ExpressionNode::Sign::Negative);
|
||||
return result;
|
||||
@@ -372,7 +372,7 @@ Expression Decimal::shallowReduce(Context & context, Preferences::AngleUnit angl
|
||||
|
||||
Expression Decimal::shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) {
|
||||
if (sign() == ExpressionNode::Sign::Negative) {
|
||||
Expression abs = setSign(ExpressionNode::Sign::Positive, &context, angleUnit);
|
||||
Expression abs = setSign(ExpressionNode::Sign::Positive);
|
||||
Opposite o;
|
||||
replaceWithInPlace(o);
|
||||
o.replaceChildAtIndexInPlace(0, abs);
|
||||
|
||||
@@ -664,8 +664,8 @@ void Multiplication::factorizeSineAndCosine(int i, int j, Context & context, Pre
|
||||
return;
|
||||
}
|
||||
Number sumPQ = Number::Addition(p, q);
|
||||
Number absP = p.clone().convert<Number>().setSign(ExpressionNode::Sign::Positive, &context, angleUnit);
|
||||
Number absQ = q.clone().convert<Number>().setSign(ExpressionNode::Sign::Positive, &context, angleUnit);
|
||||
Number absP = p.clone().convert<Number>().setSign(ExpressionNode::Sign::Positive);
|
||||
Number absQ = q.clone().convert<Number>().setSign(ExpressionNode::Sign::Positive);
|
||||
Expression tan = Tangent::Builder(x.clone());
|
||||
if (Number::NaturalOrder(absP, absQ) < 0) {
|
||||
// Replace sin(x) by tan(x) or sin(x)^p by tan(x)^p
|
||||
|
||||
Reference in New Issue
Block a user