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 PNodeIadd(PNodeI c)Adds a node to this one.intcompareToPConstant(PConstant c)voidconvertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)Internal method for extracting coefficientsPNodeIdiv(PNodeI c)Divides this by the argument.booleanequalsPNode(PNodeI node)True is nodes represent the same parse treesPNodeIexpand()complete expansion. (1+x)^2 --> 1+2*x+x^2java.lang.ObjectgetValue()inthashCode()intintValue()PNodeIinvert()inverts node i.e. 1/xbooleanisInfinity()booleanisInteger()booleanisMinusOne()booleanisNan()booleanisNegative()booleanisOne()True if node represents onebooleanisPositive()booleanisZero()True if node represents zeroPNodeImul(PNodeI c)Multiplies this by the argument.PNodeInegate()negates node i.e.PNodeIpow(PNodeI c)Raise this to the argument.PNodeIsub(PNodeI c)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.-
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:PNodeInegates node i.e. -x- Throws:
ParseException
-
add
public PNodeI add(PNodeI c) throws ParseException
Description copied from interface:PNodeIAdds a node to this one.- Specified by:
addin interfacePNodeI- Overrides:
addin classAbstractPNode- Throws:
ParseException
-
sub
public PNodeI sub(PNodeI c) throws ParseException
Description copied from interface:PNodeISubtracts the argument from this.- Specified by:
subin interfacePNodeI- Overrides:
subin classAbstractPNode- Throws:
ParseException
-
mul
public PNodeI mul(PNodeI c) throws ParseException
Description copied from interface:PNodeIMultiplies this by the argument.- Specified by:
mulin interfacePNodeI- Overrides:
mulin classAbstractPNode- Throws:
ParseException
-
div
public PNodeI div(PNodeI c) throws ParseException
Description copied from interface:PNodeIDivides this by the argument.- Specified by:
divin interfacePNodeI- Overrides:
divin classAbstractPNode- Throws:
ParseException
-
invert
public PNodeI invert() throws ParseException
Description copied from interface:PNodeIinverts node i.e. 1/x- Specified by:
invertin interfacePNodeI- Overrides:
invertin classAbstractPNode- Throws:
ParseException
-
pow
public PNodeI pow(PNodeI c) throws ParseException
Description copied from interface:PNodeIRaise this to the argument.- Specified by:
powin interfacePNodeI- Overrides:
powin classAbstractPNode- Throws:
ParseException
-
toString
public java.lang.String toString()
Description copied from interface:PNodeIProduces a string representation of the argument.
-
isZero
public boolean isZero()
Description copied from interface:PNodeITrue if node represents zero- Specified by:
isZeroin interfacePNodeI- Overrides:
isZeroin classAbstractPNode
-
isOne
public boolean isOne()
Description copied from interface:PNodeITrue if node represents one- Specified by:
isOnein interfacePNodeI- Overrides:
isOnein 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:PNodeIConverts the node to standard Jep format.- Throws:
ParseException
-
toCompactNode
public Node toCompactNode() throws ParseException
Description copied from interface:PNodeIConverts 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:PNodeITrue is nodes represent the same parse trees- Specified by:
equalsPNodein interfacePNodeI- Overrides:
equalsPNodein classAbstractPNode
-
expand
public PNodeI expand()
Description copied from interface:PNodeIcomplete 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 ParseExceptionDescription copied from interface:PNodeIInternal method for extracting coefficients- Parameters:
var- variable namepolyArray- results added to this map- Throws:
ParseException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-