|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.singularsys.aa.manipulation.Simplifier
public class Simplifier
The simplifier class simplifies expression trees. With the simplify() method, a set of simplification rules is repeatedly applied until the expression can not be simplified any more.
The simplification rules are:
Transforming negatives a - b -> a + ((-1) * b) -a -> (-1) * a Leveling Operators a + (b + c) -> sum(a, b, c) (a + b) + c -> sum(a, b, c) a * (b * c) -> mul(a, b, c) (a * b) * c -> mul(a, b, c) Simplifying Rational Expressions (a / b) / c -> a / (b * c) a / (b / c) -> (a * c) / b a * (b / c) -> (a * b) / c Expanding a * (b + c) -> a * b + a * c Collecting like terms a + (2 * a) -> (1 * a) + (2 * a) a * (a^2) -> (a^1) * (a^2) (a*C1) + (a*C2) -> a * (C1 + C2) (a^C1) * (a^C2) -> a ^ (C1 + C2) Folding Constants fun(C1, C2, ...) -> C3
Constructor Summary | |
---|---|
Simplifier()
Creates new Simplifier |
Method Summary | |
---|---|
org.nfunk.jep.Node |
simplify(org.nfunk.jep.Node topNode)
Simplifies an expression, and returns the resulting tree. |
java.lang.Object |
visit(org.nfunk.jep.ASTConstant node,
java.lang.Object data)
|
java.lang.Object |
visit(org.nfunk.jep.ASTFunNode node,
java.lang.Object data)
|
java.lang.Object |
visit(org.nfunk.jep.ASTStart node,
java.lang.Object data)
|
java.lang.Object |
visit(org.nfunk.jep.ASTVarNode node,
java.lang.Object data)
|
java.lang.Object |
visit(org.nfunk.jep.SimpleNode node,
java.lang.Object data)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Simplifier()
Method Detail |
---|
public org.nfunk.jep.Node simplify(org.nfunk.jep.Node topNode) throws java.lang.Exception
The tree under topNode is not changed. A new tree is created and returned.
java.lang.Exception
public java.lang.Object visit(org.nfunk.jep.ASTFunNode node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
public java.lang.Object visit(org.nfunk.jep.ASTConstant node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
public java.lang.Object visit(org.nfunk.jep.ASTVarNode node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
public java.lang.Object visit(org.nfunk.jep.ASTStart node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
public java.lang.Object visit(org.nfunk.jep.SimpleNode node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |