|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.lsmp.djep.xjep.DoNothingVisitor org.lsmp.djep.sjep.PolynomialCreator
public class PolynomialCreator
Main entry point for simplification routines.
Uses a complete reworking of the ways equations are represented. A tree structure is built from Polynomials, Monomials, PVariable etc. An equation like
1+2 x^2+3 x y+4 x sin(y)is represented as
Polynomial([ Monomial(2.0,[PVariable(x)],[2])]), Monomial(3.0,[x,y],[1,1]), Monomial(4.0,[x,Function(sin,arg)],[1,1]) ])
A total ordering of all expressions is used. As the representation is constructed the total ordering of terms is maintained. This helps ensure that polynomials are always in their simplest form and also allows comparison of equations.
The following sequence illustrates current ordering. This ordering may change without warning.
Constructor Summary | |
---|---|
PolynomialCreator(XJep j)
|
Method Summary | |
---|---|
int |
compare(Node node1,
Node node2)
Compares two nodes. |
PNodeI |
createPoly(Node node)
Converts an expression into the polynomial representation. |
boolean |
equals(Node node1,
Node node2)
Compares two nodes. |
Node |
expand(Node node)
Expands an expression. |
Node |
simplify(Node node)
Simplifies an expression. |
java.lang.Object |
visit(ASTConstant node,
java.lang.Object data)
|
java.lang.Object |
visit(ASTFunNode node,
java.lang.Object data)
|
java.lang.Object |
visit(ASTVarNode node,
java.lang.Object data)
|
Methods inherited from class org.lsmp.djep.xjep.DoNothingVisitor |
---|
acceptChildrenAsArray, visit, visit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PolynomialCreator(XJep j)
Method Detail |
---|
public PNodeI createPoly(Node node) throws ParseException
node
- top node of expression
ParseException
- if expression cannot be converted.public Node simplify(Node node) throws ParseException
node
- top node to expression to be simplified.
ParseException
public Node expand(Node node) throws ParseException
(1+x)^3 -> 1+3x+3x^2+x^3
node
- top node to expression to be simplified.
ParseException
public int compare(Node node1, Node node2) throws ParseException
node1
- node2
-
ParseException
public boolean equals(Node node1, Node node2) throws ParseException
node1
- node2
-
ParseException
public java.lang.Object visit(ASTConstant node, java.lang.Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
public java.lang.Object visit(ASTVarNode node, java.lang.Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
public java.lang.Object visit(ASTFunNode node, java.lang.Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |