[poincare] Add rule (-1256)^(1/3)->e^(iPI/3)2*157^(1/3)

Change-Id: I3fd692bef317af4d35b6e38551f81bc306d131c4
This commit is contained in:
Émilie Feral
2017-09-29 17:26:01 +02:00
parent 11d0ad31cf
commit 71cfc5d861

View File

@@ -6,6 +6,8 @@
#include <poincare/multiplication.h>
#include <poincare/power.h>
#include <poincare/arithmetic.h>
#include <poincare/symbol.h>
#include <ion.h>
bool Poincare::Simplification::RationalPowerTransform(Expression * captures[]) {
Power * p0 = static_cast<Power *>(captures[0]);
@@ -40,7 +42,15 @@ bool Poincare::Simplification::RationalPowerTransform(Expression * captures[]) {
return false;
}
if (i0->isNegative()) {
// TODO if i0.isNegtative?
const Symbol * exp = new Symbol(Ion::Charset::Exponential);
const Symbol * iComplex = new Symbol(Ion::Charset::IComplex);
const Symbol * pi = new Symbol(Ion::Charset::SmallPi);
const Expression * multOperands[4] = {iComplex, pi, i1->clone(), p1->clone()};
Multiplication * mExp = new Multiplication(multOperands, 4, false);
const Expression * powOperands[2] = {exp, mExp};
const Power * pExp = new Power(powOperands, false);
const Expression * operand[1] = {pExp};
m->addOperands(operand, 1);
}
m->replaceOperand(i1, new Integer(r1), true);
const Expression * powerOperands[2] = {new Integer(r2), p1};