Class PVariable
- java.lang.Object
-
- com.singularsys.extensions.polynomials.AbstractPNode
-
- com.singularsys.extensions.polynomials.PVariable
-
public class PVariable extends AbstractPNode
Represents a variable.- Author:
- Rich Morris Created on 14-Dec-2004
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.extensions.polynomials.AbstractPNode
pc
-
-
Constructor Summary
Constructors Constructor Description PVariable(PolynomialCreator pc, Variable var)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PNodeI
add(PNodeI node)
Adds a node to this one.int
compareTo(PVariable vf)
this < arg ---> -1 this > arg ---> 1void
convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)
Internal method for extracting coefficientsboolean
equals(java.lang.Object obj)
True is nodes represent the same parse treesboolean
equalsIgnoreConstant(PNodeI node)
boolean
equalsPNode(PNodeI node)
True is nodes represent the same parse treesPNodeI
expand()
complete expansion. (1+x)^2 --> 1+2*x+x^2java.lang.String
getName()
Variable
getVariable()
int
hashCode()
PNodeI
negate()
negates node i.e.PNodeI
sub(PNodeI node)
Subtracts the argument from this.Node
toCompactNode()
Converts to a more efficient Jep representation.Node
toNode()
Converts the node to standard Jep format.java.lang.String
toString()
Produces a string representation of the argument.
-
-
-
Constructor Detail
-
PVariable
public PVariable(PolynomialCreator pc, Variable var)
-
-
Method Detail
-
equalsPNode
public boolean equalsPNode(PNodeI node)
Description copied from interface:PNodeI
True is nodes represent the same parse trees- Specified by:
equalsPNode
in interfacePNodeI
- Overrides:
equalsPNode
in classAbstractPNode
-
add
public PNodeI add(PNodeI node) throws ParseException
Description copied from interface:PNodeI
Adds a node to this one.- Specified by:
add
in interfacePNodeI
- Overrides:
add
in classAbstractPNode
- Throws:
ParseException
-
sub
public PNodeI sub(PNodeI node) throws ParseException
Description copied from interface:PNodeI
Subtracts the argument from this.- Specified by:
sub
in interfacePNodeI
- Overrides:
sub
in classAbstractPNode
- Throws:
ParseException
-
compareTo
public int compareTo(PVariable vf)
this < arg ---> -1 this > arg ---> 1
-
toString
public java.lang.String toString()
Description copied from interface:PNodeI
Produces a string representation of the argument.
-
toNode
public Node toNode() throws ParseException
Description copied from interface:PNodeI
Converts the node to standard Jep format.- Throws:
ParseException
-
toCompactNode
public Node toCompactNode() throws ParseException
Description copied from interface:PNodeI
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
-
expand
public PNodeI expand()
Description copied from interface:PNodeI
complete expansion. (1+x)^2 --> 1+2*x+x^2
-
getVariable
public Variable getVariable()
- Returns:
- Returns the variable.
-
getName
public java.lang.String getName()
- Returns:
- Returns the name of the variable
-
convertToPolyArray
public void convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray) throws ParseException
Description copied from interface:PNodeI
Internal method for extracting coefficients- Parameters:
var
- variable namepolyArray
- results added to this map- Throws:
ParseException
-
negate
public PNodeI negate() throws ParseException
Description copied from interface:PNodeI
negates node i.e. -x- Throws:
ParseException
-
equalsIgnoreConstant
public boolean equalsIgnoreConstant(PNodeI node)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:PNodeI
True is nodes represent the same parse trees- Specified by:
equals
in interfacePNodeI
- Overrides:
equals
in classAbstractPNode
-
-