Interface PNodeI
-
- All Superinterfaces:
java.lang.Comparable<PNodeI>,java.io.Serializable
- All Known Implementing Classes:
AbstractPNode,Monomial,PConstant,PFunction,Polynomial,POperator,PVariable
public interface PNodeI extends java.lang.Comparable<PNodeI>, java.io.Serializable
An element in a polynomial representation of an expression. Provides the main routines for creating, comparing and manipulating polynomials.- Author:
- Rich Morris Created on 17-Dec-2004
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PNodeIadd(PNodeI node)Adds a node to this one.intcompareTo(PNodeI fun)Compares this expression to argument.voidconvertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)Internal method for extracting coefficientsPNodeIdiv(PNodeI node)Divides this by the argument.booleanequals(java.lang.Object o)True is nodes represent the same parse treesbooleanequalsPNode(PNodeI node)True is nodes represent the same parse treesPNodeIexpand()complete expansion. (1+x)^2 --> 1+2*x+x^2PNodeIinvert()inverts node i.e. 1/xbooleanisOne()True if node represents onebooleanisZero()True if node represents zeroPNodeImul(PNodeI node)Multiplies this by the argument.PNodeInegate()negates node i.e.PNodeIpow(PNodeI node)Raise this to the argument.PNodeIsub(PNodeI node)Subtracts the argument from this.NodetoCompactNode()Converts to a more efficient Jep representation.NodetoNode()Converts the node to standard Jep format.java.lang.StringtoString()Produces a string representation of the argument.
-
-
-
Method Detail
-
add
PNodeI add(PNodeI node) throws ParseException
Adds a node to this one.- Throws:
ParseException
-
sub
PNodeI sub(PNodeI node) throws ParseException
Subtracts the argument from this.- Throws:
ParseException
-
negate
PNodeI negate() throws ParseException
negates node i.e. -x- Throws:
ParseException
-
mul
PNodeI mul(PNodeI node) throws ParseException
Multiplies this by the argument.- Throws:
ParseException
-
div
PNodeI div(PNodeI node) throws ParseException
Divides this by the argument.- Throws:
ParseException
-
pow
PNodeI pow(PNodeI node) throws ParseException
Raise this to the argument.- Throws:
ParseException
-
invert
PNodeI invert() throws ParseException
inverts node i.e. 1/x- Throws:
ParseException
-
equalsPNode
boolean equalsPNode(PNodeI node)
True is nodes represent the same parse trees
-
equals
boolean equals(java.lang.Object o)
True is nodes represent the same parse trees- Overrides:
equalsin classjava.lang.Object
-
compareTo
int compareTo(PNodeI fun)
Compares this expression to argument. Uses a total ordering of expressions. Returns positive if this node comes after the argument.- Specified by:
compareToin interfacejava.lang.Comparable<PNodeI>
-
toNode
Node toNode() throws ParseException
Converts the node to standard Jep format.- Throws:
ParseException
-
toCompactNode
Node toCompactNode() throws ParseException
Converts to a more efficient Jep representation. Exploits the feature of the Add and Multiply operators which allow the operators to work as n-ary operators. Order of elements is altered to make for more efficient operation.- Returns:
- Throws:
ParseException
-
toString
java.lang.String toString()
Produces a string representation of the argument.- Overrides:
toStringin classjava.lang.Object
-
isZero
boolean isZero()
True if node represents zero
-
isOne
boolean isOne()
True if node represents one
-
expand
PNodeI expand() throws ParseException
complete expansion. (1+x)^2 --> 1+2*x+x^2- Throws:
ParseException
-
convertToPolyArray
void convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray) throws ParseExceptionInternal method for extracting coefficients- Parameters:
var- variable namepolyArray- results added to this map- Throws:
ParseException
-
-