Class PVariable

java.lang.Object
com.singularsys.extensions.polynomials.AbstractPNode
com.singularsys.extensions.polynomials.PVariable
All Implemented Interfaces:
PNodeI, Serializable, Comparable<PNodeI>

public class PVariable extends AbstractPNode
Represents a variable.
Author:
Rich Morris Created on 14-Dec-2004
See Also:
  • Constructor Details

  • Method Details

    • equalsPNode

      public boolean equalsPNode(PNodeI node)
      Description copied from interface: PNodeI
      True is nodes represent the same parse trees
      Specified by:
      equalsPNode in interface PNodeI
      Overrides:
      equalsPNode in class AbstractPNode
    • add

      public PNodeI add(PNodeI node) throws ParseException
      Description copied from class: AbstractPNode
      Returns the sum of this node and argument
      Specified by:
      add in interface PNodeI
      Overrides:
      add in class AbstractPNode
      Parameters:
      node - to add
      Returns:
      node representing the sum
      Throws:
      ParseException - on error
    • sub

      public PNodeI sub(PNodeI node) throws ParseException
      Description copied from class: AbstractPNode
      Returns the difference between this node and argument
      Specified by:
      sub in interface PNodeI
      Overrides:
      sub in class AbstractPNode
      Parameters:
      node - to subtract
      Returns:
      node representing the difference
      Throws:
      ParseException - on error
    • compareTo

      public int compareTo(PVariable vf)
      this < arg ---> -1 this > arg ---> 1
    • toString

      public String toString()
      Description copied from interface: PNodeI
      Produces a string representation of the argument.
      Specified by:
      toString in interface PNodeI
      Overrides:
      toString in class Object
    • 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 String getName()
      Returns:
      Returns the name of the variable
    • convertToPolyArray

      public void convertToPolyArray(String var, Map<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
    • negate

      public PNodeI negate()
      Description copied from interface: PNodeI
      negates node i.e. -x
    • equalsIgnoreConstant

      public boolean equalsIgnoreConstant(PNodeI node)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface PNodeI
      Overrides:
      equals in class AbstractPNode
    • substitute

      public PNodeI substitute(PVariable var, PNodeI sub) throws ParseException
      Description copied from interface: PNodeI
      Substitute all occurrence of variable with its replacement.
      Parameters:
      var - the variable
      sub - the replacement
      Returns:
      Throws:
      ParseException
    • toString

      public String toString(NumberFormat nf)