Class PVariable

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

    public class PVariable
    extends AbstractPNode
    Represents a variable.
    Author:
    Rich Morris Created on 14-Dec-2004
    See Also:
    Serialized Form
    • Method Detail

      • 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.
        Specified by:
        toString in interface PNodeI
        Overrides:
        toString in class java.lang.Object
      • 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 name
        polyArray - results added to this map
        Throws:
        ParseException
      • equalsIgnoreConstant

        public boolean equalsIgnoreConstant​(PNodeI node)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.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 interface PNodeI
        Overrides:
        equals in class AbstractPNode