Class PConstant

  • All Implemented Interfaces:
    PNodeI, java.io.Serializable, java.lang.Comparable<PNodeI>

    public class PConstant
    extends AbstractPNode
    Represents a constant.
    Author:
    Rich Morris Created on 14-Dec-2004
    See Also:
    Serialized Form
    • Constructor Detail

    • Method Detail

      • toString

        public java.lang.String toString()
        Description copied from interface: PNodeI
        Produces a string representation of the argument.
        Specified by:
        toString in interface PNodeI
        Overrides:
        toString in class java.lang.Object
      • isZero

        public boolean isZero()
        Description copied from interface: PNodeI
        True if node represents zero
        Specified by:
        isZero in interface PNodeI
        Overrides:
        isZero in class AbstractPNode
      • isOne

        public boolean isOne()
        Description copied from interface: PNodeI
        True if node represents one
        Specified by:
        isOne in interface PNodeI
        Overrides:
        isOne in class AbstractPNode
      • 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()
      • 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)
      • 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 name
        polyArray - results added to this map
        Throws:
        ParseException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object