Class PFunction

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

public class PFunction extends AbstractPNode
Represents a function.
Author:
Rich Morris Created on 15-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
    • hashCode

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

      public int compareTo(PFunction fun)
    • 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() throws ParseException
      Description copied from interface: PNodeI
      complete expansion. (1+x)^2 --> 1+2*x+x^2
      Throws:
      ParseException
    • getName

      public String getName()
      Returns:
      Returns the name of the function.
    • getPfmc

      public PostfixMathCommandI getPfmc()
      Returns:
      Returns the PostfixMathCommandI for the function.
    • getNArgs

      public int getNArgs()
      Returns:
      the number of arguments
    • getArg

      public PNodeI getArg(int i)
      Parameters:
      i -
      Returns:
      returns the i-th argument
    • 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
    • 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
    • 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
    • toString

      public String toString(NumberFormat nf)