mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 01:29:58 +01:00
[poincare] Fix infinite loop in power
Change-Id: I9b1ce1500303cbe880a75ac87c09a36721426332
This commit is contained in:
@@ -270,9 +270,11 @@ Expression * Power::shallowReduce(Context& context, AngleUnit angleUnit) {
|
||||
if (operand(1)->type() == Type::Rational && static_cast<Rational *>(editableOperand(1))->denominator().isOne()) {
|
||||
return simplifyPowerMultiplication(m, editableOperand(1), context, angleUnit);
|
||||
}
|
||||
// (a*b*...)^r -> |a|^r*(sign(a)*b*)^r if a rational
|
||||
// (a*b*...)^r -> |a|^r*(sign(a)*b*...)^r if a rational
|
||||
for (int i = 0; i < m->numberOfOperands(); i++) {
|
||||
if (m->operand(i)->sign() == Sign::Positive || m->operand(i)->type() == Type::Rational) {
|
||||
// a is signed and a != -1
|
||||
if (m->operand(i)->sign() != Sign::Unknown && (m->operand(i)->type() != Type::Rational || !static_cast<const Rational *>(m->operand(i))->isMinusOne())) {
|
||||
//if (m->operand(i)->sign() == Sign::Positive || m->operand(i)->type() == Type::Rational) {
|
||||
Expression * r = editableOperand(1);
|
||||
Expression * rCopy = r->clone();
|
||||
Expression * factor = m->editableOperand(i);
|
||||
|
||||
@@ -478,6 +478,7 @@ QUIZ_CASE(poincare_simplify_easy) {
|
||||
assert_parsed_expression_simplify_to("10^log(P)", "P");
|
||||
assert_parsed_expression_simplify_to("log(1/R(2))", "-log(2)/2");
|
||||
assert_parsed_expression_simplify_to("log(-I)", "log(-I)");
|
||||
assert_parsed_expression_simplify_to("R(-I)", "R(-I)");
|
||||
|
||||
/* This does not work but should not as it is above k_primorial32 = 1*3*5*7*11*... (product of first 32 primes. */
|
||||
//assert_parsed_expression_simplify_to("1881676377434183981909562699940347954480361860897069^(1/3)", "123456789123456789");
|
||||
|
||||
Reference in New Issue
Block a user