public class PolynomialCreator extends DoNothingVisitor
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 and Description |
---|
PolynomialCreator(XJep j) |
Modifier and Type | Method and Description |
---|---|
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.
|
Object |
visit(ASTConstant node,
Object data) |
Object |
visit(ASTFunNode node,
Object data) |
Object |
visit(ASTVarNode node,
Object data) |
visit, visit
public PolynomialCreator(XJep j)
public PNodeI createPoly(Node node) throws ParseException
node
- top node of expressionParseException
- 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 Object visit(ASTConstant node, Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
public Object visit(ASTVarNode node, Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
public Object visit(ASTFunNode node, Object data) throws ParseException
visit
in interface ParserVisitor
visit
in class DoNothingVisitor
ParseException
Jas4pp 1.5 © Java Analysis Studio for Particle Physics