Class PConstant
- java.lang.Object
-
- com.singularsys.extensions.polynomials.AbstractPNode
-
- com.singularsys.extensions.polynomials.PConstant
-
public class PConstant extends AbstractPNode
Represents a constant.- 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 PConstant(PolynomialCreator pc, java.lang.Object o)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PNodeI
add(PNodeI c)
Adds a node to this one.int
compareToPConstant(PConstant c)
void
convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)
Internal method for extracting coefficientsPNodeI
div(PNodeI c)
Divides this by the argument.boolean
equalsPNode(PNodeI node)
True is nodes represent the same parse treesPNodeI
expand()
complete expansion. (1+x)^2 --> 1+2*x+x^2java.lang.Object
getValue()
int
hashCode()
int
intValue()
PNodeI
invert()
inverts node i.e. 1/xboolean
isInfinity()
boolean
isInteger()
boolean
isMinusOne()
boolean
isNan()
boolean
isNegative()
boolean
isOne()
True if node represents oneboolean
isPositive()
boolean
isZero()
True if node represents zeroPNodeI
mul(PNodeI c)
Multiplies this by the argument.PNodeI
negate()
negates node i.e.PNodeI
pow(PNodeI c)
Raise this to the argument.PNodeI
sub(PNodeI c)
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.-
Methods inherited from class com.singularsys.extensions.polynomials.AbstractPNode
compareTo, equals
-
-
-
-
Constructor Detail
-
PConstant
public PConstant(PolynomialCreator pc, java.lang.Object o)
-
-
Method Detail
-
negate
public PNodeI negate() throws ParseException
Description copied from interface:PNodeI
negates node i.e. -x- Throws:
ParseException
-
add
public PNodeI add(PNodeI c) 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 c) throws ParseException
Description copied from interface:PNodeI
Subtracts the argument from this.- Specified by:
sub
in interfacePNodeI
- Overrides:
sub
in classAbstractPNode
- Throws:
ParseException
-
mul
public PNodeI mul(PNodeI c) throws ParseException
Description copied from interface:PNodeI
Multiplies this by the argument.- Specified by:
mul
in interfacePNodeI
- Overrides:
mul
in classAbstractPNode
- Throws:
ParseException
-
div
public PNodeI div(PNodeI c) throws ParseException
Description copied from interface:PNodeI
Divides this by the argument.- Specified by:
div
in interfacePNodeI
- Overrides:
div
in classAbstractPNode
- Throws:
ParseException
-
invert
public PNodeI invert() throws ParseException
Description copied from interface:PNodeI
inverts node i.e. 1/x- Specified by:
invert
in interfacePNodeI
- Overrides:
invert
in classAbstractPNode
- Throws:
ParseException
-
pow
public PNodeI pow(PNodeI c) throws ParseException
Description copied from interface:PNodeI
Raise this to the argument.- Specified by:
pow
in interfacePNodeI
- Overrides:
pow
in classAbstractPNode
- Throws:
ParseException
-
toString
public java.lang.String toString()
Description copied from interface:PNodeI
Produces a string representation of the argument.
-
isZero
public boolean isZero()
Description copied from interface:PNodeI
True if node represents zero- Specified by:
isZero
in interfacePNodeI
- Overrides:
isZero
in classAbstractPNode
-
isOne
public boolean isOne()
Description copied from interface:PNodeI
True if node represents one- Specified by:
isOne
in interfacePNodeI
- Overrides:
isOne
in classAbstractPNode
-
isMinusOne
public boolean isMinusOne()
-
isInfinity
public boolean isInfinity()
-
isNan
public boolean isNan()
-
isPositive
public boolean isPositive()
-
isNegative
public boolean isNegative()
-
isInteger
public boolean isInteger()
-
intValue
public int intValue()
-
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
-
compareToPConstant
public int compareToPConstant(PConstant c)
-
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
-
expand
public PNodeI expand()
Description copied from interface:PNodeI
complete expansion. (1+x)^2 --> 1+2*x+x^2
-
getValue
public java.lang.Object getValue()
- Returns:
- Returns the value.
-
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
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-