mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Expression::mapOnMatrixChild -> mapOnMatrixFirstChild
This commit is contained in:
@@ -214,7 +214,7 @@ public:
|
||||
void simplifyAndApproximate(Expression * simplifiedExpression, Expression * approximateExpression, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, bool symbolicComputation = true);
|
||||
Expression reduce(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit);
|
||||
|
||||
Expression mapOnMatrixChild(ExpressionNode::ReductionContext reductionContext);
|
||||
Expression mapOnMatrixFirstChild(ExpressionNode::ReductionContext reductionContext);
|
||||
static Expression ExpressionWithoutSymbols(Expression expressionWithSymbols, Context * context);
|
||||
Expression radianToDegree();
|
||||
Expression degreeToRadian();
|
||||
|
||||
@@ -37,7 +37,7 @@ Expression AbsoluteValue::shallowReduce(ExpressionNode::ReductionContext reducti
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.isReal(reductionContext.context())) {
|
||||
float app = c.node()->approximate(float(), reductionContext.context(), reductionContext.complexFormat(), reductionContext.angleUnit()).toScalar();
|
||||
|
||||
@@ -57,7 +57,7 @@ Expression ArcCosine::shallowReduce(ExpressionNode::ReductionContext reductionCo
|
||||
}
|
||||
}
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
return Trigonometry::shallowReduceInverseFunction(*this, reductionContext);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ Expression ArcSine::shallowReduce(ExpressionNode::ReductionContext reductionCont
|
||||
}
|
||||
}
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
return Trigonometry::shallowReduceInverseFunction(*this, reductionContext);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ Expression ArcTangent::shallowReduce(ExpressionNode::ReductionContext reductionC
|
||||
}
|
||||
}
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
return Trigonometry::shallowReduceInverseFunction(*this, reductionContext);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ Expression Ceiling::shallowReduce(ExpressionNode::ReductionContext reductionCont
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.type() == ExpressionNode::Type::Constant) {
|
||||
Constant s = static_cast<Constant&>(c);
|
||||
|
||||
@@ -43,7 +43,7 @@ Expression ComplexArgument::shallowReduce(ExpressionNode::ReductionContext reduc
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
bool real = c.isReal(reductionContext.context());
|
||||
if (real) {
|
||||
|
||||
@@ -41,7 +41,7 @@ Expression Conjugate::shallowReduce(ExpressionNode::ReductionContext reductionCo
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.isReal(reductionContext.context())) {
|
||||
replaceWithInPlace(c);
|
||||
|
||||
@@ -43,7 +43,7 @@ Expression Cosine::shallowReduce(ExpressionNode::ReductionContext reductionConte
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
return Trigonometry::shallowReduceDirectFunction(*this, reductionContext);
|
||||
}
|
||||
|
||||
@@ -530,8 +530,10 @@ Expression Expression::ExpressionWithoutSymbols(Expression e, Context * context)
|
||||
return e;
|
||||
}
|
||||
|
||||
Expression Expression::mapOnMatrixChild(ExpressionNode::ReductionContext reductionContext) {
|
||||
assert(numberOfChildren() == 1 && childAtIndex(0).type() == ExpressionNode::Type::Matrix);
|
||||
Expression Expression::mapOnMatrixFirstChild(ExpressionNode::ReductionContext reductionContext) {
|
||||
/* For now, the matrix child on which the mapping must be done is always at
|
||||
* the index 0. */
|
||||
assert(childAtIndex(0).type() == ExpressionNode::Type::Matrix);
|
||||
Expression c = childAtIndex(0);
|
||||
Matrix matrix = Matrix::Builder();
|
||||
for (int i = 0; i < c.numberOfChildren(); i++) {
|
||||
|
||||
@@ -86,7 +86,7 @@ Expression Factorial::shallowReduce(ExpressionNode::ReductionContext reductionCo
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.type() == ExpressionNode::Type::Rational) {
|
||||
Rational r = c.convert<Rational>();
|
||||
|
||||
@@ -44,7 +44,7 @@ Expression Floor::shallowReduce(ExpressionNode::ReductionContext reductionContex
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.type() == ExpressionNode::Type::Constant) {
|
||||
Constant s = static_cast<Constant &>(c);
|
||||
|
||||
@@ -41,7 +41,7 @@ Expression FracPart::shallowReduce(ExpressionNode::ReductionContext reductionCon
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.type() != ExpressionNode::Type::Rational) {
|
||||
return *this;
|
||||
|
||||
@@ -16,7 +16,7 @@ Expression HyperbolicTrigonometricFunction::shallowReduce(ExpressionNode::Reduct
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ Expression ImaginaryPart::shallowReduce(ExpressionNode::ReductionContext reducti
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.isReal(reductionContext.context())) {
|
||||
Expression result = Rational::Builder(0);
|
||||
|
||||
@@ -95,7 +95,7 @@ Expression CommonLogarithm::shallowReduce(ExpressionNode::ReductionContext reduc
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
Logarithm log = Logarithm::Builder(childAtIndex(0), Rational::Builder(10));
|
||||
replaceWithInPlace(log);
|
||||
@@ -209,7 +209,7 @@ Expression Logarithm::shallowReduce(ExpressionNode::ReductionContext reductionCo
|
||||
|
||||
// log(m) with m Matrix
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
@@ -32,7 +32,7 @@ Expression NaperianLogarithm::shallowReduce(ExpressionNode::ReductionContext red
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
Logarithm l = Logarithm::Builder(c, Constant::Builder(UCodePointScriptSmallE));
|
||||
replaceWithInPlace(l);
|
||||
|
||||
@@ -33,7 +33,7 @@ Expression RealPart::shallowReduce(ExpressionNode::ReductionContext reductionCon
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
if (c.isReal(reductionContext.context())) {
|
||||
replaceWithInPlace(c);
|
||||
|
||||
@@ -51,7 +51,7 @@ Expression Round::shallowReduce(ExpressionNode::ReductionContext reductionContex
|
||||
return result;
|
||||
}
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
/* We reduce only round(Rational, Rational). We do not reduce
|
||||
* round(Float, Float) which is equivalent to what is done in approximate. */
|
||||
|
||||
@@ -43,7 +43,7 @@ Expression Sine::shallowReduce(ExpressionNode::ReductionContext reductionContext
|
||||
}
|
||||
}
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
return Trigonometry::shallowReduceDirectFunction(*this, reductionContext);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ Expression Tangent::shallowReduce(ExpressionNode::ReductionContext reductionCont
|
||||
}
|
||||
|
||||
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
|
||||
return mapOnMatrixChild(reductionContext);
|
||||
return mapOnMatrixFirstChild(reductionContext);
|
||||
}
|
||||
|
||||
Expression newExpression = Trigonometry::shallowReduceDirectFunction(*this, reductionContext);
|
||||
|
||||
Reference in New Issue
Block a user