mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 17:20:53 +01:00
[poincare] Complete implementation of AbsoluteValue::immediateSimplify
Change-Id: Iedc4d680ad8861932af96a5ec6f3a2289db9f346
This commit is contained in:
@@ -22,6 +22,11 @@ Expression * AbsoluteValue::immediateSimplify() {
|
||||
if (operand(0)->sign() > 0) {
|
||||
return replaceWith(const_cast<Expression *>(operand(0)), true);
|
||||
}
|
||||
if (operand(0)->sign() < 0) {
|
||||
Expression * op = const_cast<Expression *>(operand(0));
|
||||
Expression * newOp = op->turnIntoPositive();
|
||||
return replaceWith(newOp, true);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ QUIZ_CASE(poincare_simplify_easy) {
|
||||
assert_parsed_expression_simplify_to("R(x*144*P^2)", "12*P*R(x)");
|
||||
assert_parsed_expression_simplify_to("R(x*144*P)", "12*R(xP)");
|
||||
assert_parsed_expression_simplify_to("abs(P)", "P");
|
||||
assert_parsed_expression_simplify_to("abs(-P)", "P");
|
||||
assert_parsed_expression_simplify_to("R(2)*R(3)", "R(6)");
|
||||
assert_parsed_expression_simplify_to("2*2^P", "2*2^P");
|
||||
assert_parsed_expression_simplify_to("A-A", "0");
|
||||
|
||||
Reference in New Issue
Block a user