Class Monomial
- java.lang.Object
-
- com.singularsys.extensions.polynomials.AbstractPNode
-
- com.singularsys.extensions.polynomials.Monomial
-
public class Monomial extends AbstractPNode
Represents an immutable monomial a x^i * y^j * ... * z^k, a constant.- 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.intcompareTo(PNodeI node)Compare this to argument. x < y 2 x < 3 x x < x^2 x^2 < x^3 x < x y TODO x y < x^2voidconvertToPolyArray(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^2PConstantgetCoeff()intgetNVars()PNodeIgetPower(int i)Returns the i-th powerPNodeIgetVar(int i)Returns the i-th variableinthashCode()PNodeIinvert()inverts node i.e. 1/xPNodeImul(PNodeI node)Multiplies this by the argument.PNodeInegate()negates node i.e.PNodeIpow(PNodeI pow)Raise this to the argument.PNodeIsub(PNodeI node)Subtracts the argument from this.NodetoCompactNode()Converts to a more efficient Jep representation.MutableMonomialtoMutiableMonomial()NodetoNode()Converts the node to standard Jep format.java.lang.StringtoString()Produces a string representation of the argument.static PNodeIvalueOf(PolynomialCreator pc, PConstant c, PNodeI v)static PNodeIvalueOf(PolynomialCreator pc, PConstant coefficient, PNodeI[] terms, PNodeI[] pows)static PNodeIvalueOf(PolynomialCreator pc, PConstant c, PNodeI node, PNodeI power)-
Methods inherited from class com.singularsys.extensions.polynomials.AbstractPNode
equals, isOne, isZero
-
-
-
-
Method Detail
-
valueOf
public static PNodeI valueOf(PolynomialCreator pc, PConstant c, PNodeI v)
-
valueOf
public static PNodeI valueOf(PolynomialCreator pc, PConstant c, PNodeI node, PNodeI power)
-
valueOf
public static PNodeI valueOf(PolynomialCreator pc, PConstant coefficient, PNodeI[] terms, PNodeI[] pows)
-
toMutiableMonomial
public MutableMonomial toMutiableMonomial()
-
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
-
pow
public PNodeI pow(PNodeI pow) throws ParseException
Description copied from interface:PNodeIRaise this to the argument.- Specified by:
powin interfacePNodeI- Overrides:
powin classAbstractPNode- Throws:
ParseException
-
negate
public PNodeI negate() throws ParseException
Description copied from interface:PNodeInegates node i.e. -x- Throws:
ParseException
-
invert
public PNodeI invert() throws ParseException
Description copied from interface:PNodeIinverts node i.e. 1/x- Specified by:
invertin interfacePNodeI- Overrides:
invertin classAbstractPNode- 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
-
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
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(PNodeI node)
Compare this to argument. x < y 2 x < 3 x x < x^2 x^2 < x^3 x < x y TODO x y < x^2- Specified by:
compareToin interfacejava.lang.Comparable<PNodeI>- Specified by:
compareToin interfacePNodeI- Overrides:
compareToin classAbstractPNode- Returns:
- -1,0,1
-
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
Description copied from interface:PNodeIConverts 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:PNodeIcomplete expansion. (1+x)^2 --> 1+2*x+x^2- Throws:
ParseException
-
getCoeff
public PConstant getCoeff()
- Returns:
- Returns the coefficient.
-
getNVars
public int getNVars()
- Returns:
- return the number of variables.
-
getVar
public PNodeI getVar(int i)
Returns the i-th variable- Parameters:
i-- Returns:
- PNodeI for the i-th variable in product
-
getPower
public PNodeI getPower(int i)
Returns the i-th power- Parameters:
i-- Returns:
- PNodeI for the power of the i-th variable in product
-
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
-
-