From 71cfc5d8615568ed2deaf92fe76fe94bbf39ebd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 29 Sep 2017 17:26:01 +0200 Subject: [PATCH] [poincare] Add rule (-1256)^(1/3)->e^(iPI/3)2*157^(1/3) Change-Id: I3fd692bef317af4d35b6e38551f81bc306d131c4 --- .../transform/rational_power_transform.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/poincare/src/simplification/transform/rational_power_transform.cpp b/poincare/src/simplification/transform/rational_power_transform.cpp index 2d0519799..d3292fd12 100644 --- a/poincare/src/simplification/transform/rational_power_transform.cpp +++ b/poincare/src/simplification/transform/rational_power_transform.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include bool Poincare::Simplification::RationalPowerTransform(Expression * captures[]) { Power * p0 = static_cast(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};