Class Polynomial
- java.lang.Object
-
- com.singularsys.extensions.polynomials.AbstractPNode
-
- com.singularsys.extensions.polynomials.Polynomial
-
public class Polynomial extends AbstractPNode
Represents a polynomial. i.e. a sum of terms which are typicallyMonomials, but can be anyAbstractPNode. The order of the terms is specified by the total ordering.- Author:
- Rich Morris Created on 14-Dec-2004
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.extensions.polynomials.AbstractPNode
pc
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PNodeIadd(PNodeI node)Adds a node to this one.PNodeIadd(Polynomial p)intcompareTo(PNodeI node)Compares this expression to argument.intcompareTo(Polynomial p)voidconvertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)Internal method for extracting coefficientsPNodeIdiv(PNodeI node)Divides this by the argument.booleanequalsPNode(PNodeI node)True is nodes represent the same parse treesPNodeIexpand()complete expansion. (1+x)^2 --> 1+2*x+x^2intgetNTerms()The number of terms which make up the polynomial.PNodeIgetTerm(int i)Get the n-th terminthashCode()PNodeImul(PNodeI node)Multiplies this by the argument.PNodeInegate()negates node i.e.PNodeIsub(PNodeI node)Subtracts the argument from this.PNodeIsub(Polynomial p)NodetoCompactNode()A more efficient representation.NodetoNode()Converts the node to standard Jep format.java.lang.StringtoString()Produces a string representation of the argument.static PNodeIvalueOf(PolynomialCreator pc, PNodeI[] terms)
-
-
-
Method Detail
-
valueOf
public static PNodeI valueOf(PolynomialCreator pc, PNodeI[] terms) throws ParseException
- Throws:
ParseException
-
add
public PNodeI add(PNodeI node) throws ParseException
Description copied from interface:PNodeIAdds a node to this one.- Specified by:
addin interfacePNodeI- Overrides:
addin classAbstractPNode- Throws:
ParseException
-
sub
public PNodeI sub(PNodeI node) throws ParseException
Description copied from interface:PNodeISubtracts the argument from this.- Specified by:
subin interfacePNodeI- Overrides:
subin classAbstractPNode- Throws:
ParseException
-
add
public PNodeI add(Polynomial p) throws ParseException
- Throws:
ParseException
-
sub
public PNodeI sub(Polynomial p) throws ParseException
- Throws:
ParseException
-
negate
public PNodeI negate() throws ParseException
Description copied from interface:PNodeInegates node i.e. -x- Throws:
ParseException
-
mul
public PNodeI mul(PNodeI node) throws ParseException
Description copied from interface:PNodeIMultiplies this by the argument.- Specified by:
mulin interfacePNodeI- Overrides:
mulin classAbstractPNode- Throws:
ParseException
-
div
public PNodeI div(PNodeI node) throws ParseException
Description copied from interface:PNodeIDivides this by the argument.- Specified by:
divin interfacePNodeI- Overrides:
divin classAbstractPNode- Throws:
ParseException
-
equalsPNode
public boolean equalsPNode(PNodeI node)
Description copied from interface:PNodeITrue is nodes represent the same parse trees- Specified by:
equalsPNodein interfacePNodeI- Overrides:
equalsPNodein classAbstractPNode
-
compareTo
public int compareTo(PNodeI node)
Description copied from interface:PNodeICompares this expression to argument. Uses a total ordering of expressions. Returns positive if this node comes after the argument.- Specified by:
compareToin interfacejava.lang.Comparable<PNodeI>- Specified by:
compareToin interfacePNodeI- Overrides:
compareToin classAbstractPNode
-
compareTo
public int compareTo(Polynomial p)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Description copied from interface:PNodeIProduces a string representation of the argument.
-
toNode
public Node toNode() throws ParseException
Description copied from interface:PNodeIConverts the node to standard Jep format.- Throws:
ParseException
-
toCompactNode
public Node toCompactNode() throws ParseException
A more efficient representation. Uses the- Returns:
- Throws:
ParseException
-
expand
public PNodeI expand() throws ParseException
Description copied from interface:PNodeIcomplete expansion. (1+x)^2 --> 1+2*x+x^2- Throws:
ParseException
-
getNTerms
public int getNTerms()
The number of terms which make up the polynomial.- Returns:
- the number of terms
-
getTerm
public PNodeI getTerm(int i)
Get the n-th term- Parameters:
i- index of terms- Returns:
- PNodeI for that term.
-
convertToPolyArray
public void convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray) throws ParseExceptionDescription copied from interface:PNodeIInternal method for extracting coefficients- Parameters:
var- variable namepolyArray- results added to this map- Throws:
ParseException
-
-