mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Add Parentheses around conjugate expression to easen reading:
conj(2+i)*2 --> (conj(2+i))*2
This commit is contained in:
@@ -35,6 +35,9 @@ bool AdditionNode::childNeedsUserParentheses(const Expression & child) const {
|
||||
&& child.node() != childAtIndex(0)) {
|
||||
return true;
|
||||
}
|
||||
if (child.type() == Type::Conjugate) {
|
||||
return childNeedsUserParentheses(child.childAtIndex(0));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ bool MultiplicationNode::childNeedsUserParentheses(const Expression & child) con
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (child.type() == Type::Conjugate) {
|
||||
return childNeedsUserParentheses(child.childAtIndex(0));
|
||||
}
|
||||
Type types[] = {Type::Subtraction, Type::Addition};
|
||||
return child.isOfType(types, 2);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ bool SubtractionNode::childNeedsUserParentheses(const Expression & child) const
|
||||
if (child.isNumber() && static_cast<const Number &>(child).sign() == Sign::Negative) {
|
||||
return true;
|
||||
}
|
||||
if (child.type() == Type::Conjugate) {
|
||||
return childNeedsUserParentheses(child.childAtIndex(0));
|
||||
}
|
||||
Type types[] = {Type::Subtraction, Type::Opposite, Type::Addition};
|
||||
return child.isOfType(types, 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user