Interface PNodeI
- All Superinterfaces:
Comparable<PNodeI>,Serializable
- All Known Implementing Classes:
AbstractPNode,Monomial,PConstant,PFunction,Polynomial,POperator,PVariable
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
Modifier and TypeMethodDescriptionAdds a node to this one.intCompares this expression to argument.voidconvertToPolyArray(String var, Map<Integer, PNodeI> polyArray) Internal method for extracting coefficientsDivides this by the argument.booleanbooleanequalsPNode(PNodeI node) True is nodes represent the same parse treesexpand()complete expansion. (1+x)^2 --> 1+2*x+x^2invert()inverts node i.e. 1/xbooleanisOne()True if node represents onebooleanisZero()True if node represents zeroMultiplies this by the argument.negate()negates node i.e.Raise this to the argument.Subtracts the argument from this.substitute(PVariable var, PNodeI sub) Substitute all occurrence of variable with its replacement.Converts to a more efficient Jep representation.toNode()Converts the node to standard Jep format.toString()Produces a string representation of the argument.toString(NumberFormat nf)
-
Method Details
-
add
Adds a node to this one.- Throws:
ParseException
-
sub
Subtracts the argument from this.- Throws:
ParseException
-
negate
negates node i.e. -x- Throws:
ParseException
-
mul
Multiplies this by the argument.- Throws:
ParseException
-
div
Divides this by the argument.- Throws:
ParseException
-
pow
Raise this to the argument.- Throws:
ParseException
-
invert
inverts node i.e. 1/x- Throws:
ParseException
-
equalsPNode
True is nodes represent the same parse trees -
substitute
Substitute all occurrence of variable with its replacement.- Parameters:
var- the variablesub- the replacement- Returns:
- Throws:
ParseException
-
equals
-
compareTo
Compares this expression to argument. Uses a total ordering of expressions. Returns positive if this node comes after the argument.- Specified by:
compareToin interfaceComparable<PNodeI>
-
toNode
Converts the node to standard Jep format.- Throws:
ParseException
-
toCompactNode
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
String toString()Produces a string representation of the argument. -
toString
-
isZero
boolean isZero()True if node represents zero -
isOne
boolean isOne()True if node represents one -
expand
complete expansion. (1+x)^2 --> 1+2*x+x^2- Throws:
ParseException
-
convertToPolyArray
Internal method for extracting coefficients- Parameters:
var- variable namepolyArray- results added to this map- Throws:
ParseException
-