mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] Expression::CreateComplexExpression: fix crash when creating
Polar form
This commit is contained in:
committed by
LeaNumworks
parent
4c11e73ad3
commit
984d1ff924
@@ -856,8 +856,13 @@ Expression Expression::CreateComplexExpression(Expression ra, Expression tb, Pre
|
||||
Expression norm;
|
||||
Expression exp;
|
||||
if (!isOneRa || isZeroTb) {
|
||||
assert(!isNegativeRa); // norm cannot be negative
|
||||
norm = ra;
|
||||
/* Norm cannot be negative but can be preceded by a negative sign (for
|
||||
* instance "-log(0.3)") which would lead to isNegativeRa = True. */
|
||||
if (isNegativeRa) {
|
||||
norm = Opposite::Builder(ra);
|
||||
} else {
|
||||
norm = ra;
|
||||
}
|
||||
}
|
||||
if (!isZeroRa && !isZeroTb) {
|
||||
Expression arg;
|
||||
|
||||
@@ -941,6 +941,7 @@ QUIZ_CASE(poincare_simplification_complex_format) {
|
||||
assert_parsed_expression_simplify_to("[[1,√(-1)]]", "[[1,ℯ^\u0012π/2×𝐢\u0013]]", User, Radian, Polar);
|
||||
assert_parsed_expression_simplify_to("atan(2)", "atan(2)", User, Radian, Polar);
|
||||
assert_parsed_expression_simplify_to("atan(-2)", "atan(2)×ℯ^\u0012π×𝐢\u0013", User, Radian, Polar);
|
||||
assert_parsed_expression_simplify_to("cos(42π)", "-cos(42×π)×ℯ^\x12π×𝐢\x13", User, Degree, Polar);
|
||||
|
||||
// User defined variable
|
||||
assert_parsed_expression_simplify_to("a", "a", User, Radian, Polar);
|
||||
|
||||
Reference in New Issue
Block a user