Class PFunction
- java.lang.Object
-
- com.singularsys.extensions.polynomials.AbstractPNode
-
- com.singularsys.extensions.polynomials.PFunction
-
public class PFunction extends AbstractPNode
Represents a function.- Author:
- Rich Morris Created on 15-Dec-2004
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.extensions.polynomials.AbstractPNode
pc
-
-
Constructor Summary
Constructors Constructor Description PFunction(PolynomialCreator pc, java.lang.String name, PostfixMathCommandI pfmc, PNodeI[] args)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(PFunction fun)
void
convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)
Internal method for extracting coefficientsboolean
equalsPNode(PNodeI node)
True is nodes represent the same parse treesPNodeI
expand()
complete expansion. (1+x)^2 --> 1+2*x+x^2PNodeI
getArg(int i)
java.lang.String
getName()
int
getNArgs()
PostfixMathCommandI
getPfmc()
int
hashCode()
PNodeI
negate()
negates node i.e.Node
toCompactNode()
Converts to a more efficient Jep representation.Node
toNode()
Converts the node to standard Jep format.java.lang.String
toString()
Produces a string representation of the argument.
-
-
-
Constructor Detail
-
PFunction
public PFunction(PolynomialCreator pc, java.lang.String name, PostfixMathCommandI pfmc, PNodeI[] args)
-
-
Method Detail
-
equalsPNode
public boolean equalsPNode(PNodeI node)
Description copied from interface:PNodeI
True is nodes represent the same parse trees- Specified by:
equalsPNode
in interfacePNodeI
- Overrides:
equalsPNode
in classAbstractPNode
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(PFunction fun)
-
toString
public java.lang.String toString()
Description copied from interface:PNodeI
Produces a string representation of the argument.
-
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 java.lang.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(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 namepolyArray
- results added to this map- Throws:
ParseException
-
negate
public PNodeI negate() throws ParseException
Description copied from interface:PNodeI
negates node i.e. -x- Throws:
ParseException
-
-