mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[poincare] Remove dead code
This commit is contained in:
@@ -12,8 +12,6 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
//#include "simplify/rules.h"
|
||||
|
||||
int poincare_expression_yyparse(Poincare::Expression ** expressionOutput);
|
||||
|
||||
namespace Poincare {
|
||||
@@ -149,68 +147,6 @@ template<typename T> T Expression::approximate(const char * text, Context& conte
|
||||
return result;
|
||||
}
|
||||
|
||||
/*Expression * Expression::simplify() const {
|
||||
// pre-process:
|
||||
// - remonter les noeuds de matrices en root ou les faire disparaitre
|
||||
// - division and subtraction are turned into multiplication and addition
|
||||
// - oppostive are turned into multiplication
|
||||
// - associative expression are collapsed
|
||||
// Simplify:
|
||||
// - see Romain notes
|
||||
// Post-process:
|
||||
// - pattern a+(-1)*b -> a-b
|
||||
// - pattern a*b^(-1) -> a/b
|
||||
// - pattern (-1)*a -> -a
|
||||
|
||||
|
||||
|
||||
* We make sure that the simplification is deletable.
|
||||
* Indeed, we don't want an expression with some parts deletable and some not
|
||||
*
|
||||
|
||||
// If we have a leaf node nothing can be simplified.
|
||||
if (this->numberOfOperands()==0) {
|
||||
return this->clone();
|
||||
}
|
||||
|
||||
Expression * result = this->clone();
|
||||
Expression * tmp = nullptr;
|
||||
|
||||
bool simplification_pass_was_useful = true;
|
||||
while (simplification_pass_was_useful) {
|
||||
* We recursively simplify the children expressions.
|
||||
* Note that we are sure to get the samne number of children as we had before
|
||||
*
|
||||
Expression ** simplifiedOperands = new Expression * [result->numberOfOperands()];
|
||||
for (int i = 0; i < result->numberOfOperands(); i++) {
|
||||
simplifiedOperands[i] = result->operand(i)->simplify();
|
||||
}
|
||||
|
||||
* Note that we don't need to clone the simplified children because they are
|
||||
* already cloned before. *
|
||||
tmp = result->cloneWithDifferentOperands(simplifiedOperands, result->numberOfOperands(), false);
|
||||
delete result;
|
||||
result = tmp;
|
||||
|
||||
// The table is no longer needed.
|
||||
delete [] simplifiedOperands;
|
||||
|
||||
simplification_pass_was_useful = false;
|
||||
for (int i=0; i<knumberOfSimplifications; i++) {
|
||||
const Simplification * simplification = (simplifications + i); // Pointer arithmetics
|
||||
Expression * simplified = simplification->simplify(result);
|
||||
if (simplified != nullptr) {
|
||||
simplification_pass_was_useful = true;
|
||||
delete result;
|
||||
result = simplified;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
template<typename T> T Expression::epsilon() {
|
||||
static T epsilon = sizeof(T) == sizeof(double) ? 1E-15 : 1E-7f;
|
||||
return epsilon;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
Addition(Addition(a*),b*)->Addition(a*,b*);
|
||||
Addition(Integer.a,Integer.b)->$AddIntegers(a,b);
|
||||
Addition(Integer.a,Integer.b,c*)->Addition($AddIntegers(a,b),c*);
|
||||
|
||||
Subtraction(a,b)->Addition(a,Multiplication(b,Integer[-1]));
|
||||
Addition(a, Multiplication(a,Integer[-1]))->Integer[0];
|
||||
Addition(a, Multiplication(a,Integer[-1]), b)->b;
|
||||
Addition(a, Multiplication(a,Integer[-1]), b, c*)->Addition(b,c*);
|
||||
|
||||
Addition(a,a,b*)->Addition(Multiplication(a,Integer[2]),b*);
|
||||
Addition(a,Multiplication(a,b),c*)->Addition(Multiplication(a,Addition(b,Integer[1])),c*);
|
||||
Addition(Multiplication(a,b),Multiplication(a,c),d*)->Addition(Multiplication(a,Addition(b,c)),d*);
|
||||
Addition(a,a)->Multiplication(a,Integer[2]);
|
||||
Addition(a,Multiplication(a,b))->Multiplication(a,Addition(b,Integer[1]));
|
||||
Addition(Multiplication(a,b),Multiplication(a,c))->Multiplication(a,Addition(b,c));
|
||||
|
||||
Multiplication(Multiplication(a*),b*)->Multiplication(a*,b*);
|
||||
Multiplication(Integer[0],a*)->Integer[0];
|
||||
Multiplication(Integer.a,Integer.b)->$MultiplyIntegers(a,b);
|
||||
Multiplication(Integer.a,Integer.b,c*)->Multiplication($MultiplyIntegers(a,b),c*);
|
||||
Reference in New Issue
Block a user