Class Monomial
java.lang.Object
com.singularsys.extensions.polynomials.AbstractPNode
com.singularsys.extensions.polynomials.Monomial
- All Implemented Interfaces:
PNodeI,Serializable,Comparable<PNodeI>
Represents an immutable monomial a x^i * y^j * ... * z^k, a constant.
- Author:
- Rich Morris Created on 14-Dec-2004
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.extensions.polynomials.AbstractPNode
pc -
Method Summary
Modifier and TypeMethodDescriptionReturns the sum of this node and argumentintCompare this to argument. x < y 2 x < 3 x x < x^2 x^2 < x^3 x < x y TODO x y < x^2voidconvertToPolyArray(String var, Map<Integer, PNodeI> polyArray) Internal method for extracting coefficientsDivides this by the argument.booleanequalsPNode(PNodeI node) True is nodes represent the same parse treesexpand()complete expansion. (1+x)^2 --> 1+2*x+x^2getCoeff()intgetNVars()getPower(int i) Returns the i-th powergetVar(int i) Returns the i-th variableinthashCode()invert()inverts node i.e. 1/xMultiplies this by the argument.negate()negates node i.e.Raise this to the argument.Returns the difference between this node and argumentsubstitute(PVariable var, PNodeI sub) Substitute all occurrence of variable with its replacement.Converts to a more efficient Jep representation.toNode()Converts the node to standard Jep format.toString()Produces a string representation of the argument.toString(NumberFormat nf) The total degree of the monomial.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 Details
-
valueOf
-
valueOf
-
valueOf
public static PNodeI valueOf(PolynomialCreator pc, PConstant coefficient, PNodeI[] terms, PNodeI[] pows) -
toMutableMonomial
-
mul
Description copied from interface:PNodeIMultiplies this by the argument.- Specified by:
mulin interfacePNodeI- Overrides:
mulin classAbstractPNode- Throws:
ParseException
-
div
Description copied from interface:PNodeIDivides this by the argument.- Specified by:
divin interfacePNodeI- Overrides:
divin classAbstractPNode- Throws:
ParseException
-
pow
Description copied from interface:PNodeIRaise this to the argument.- Specified by:
powin interfacePNodeI- Overrides:
powin classAbstractPNode- Throws:
ParseException
-
negate
Description copied from interface:PNodeInegates node i.e. -x- Throws:
ParseException
-
invert
Description copied from interface:PNodeIinverts node i.e. 1/x- Specified by:
invertin interfacePNodeI- Overrides:
invertin classAbstractPNode- Throws:
ParseException
-
add
Description copied from class:AbstractPNodeReturns the sum of this node and argument- Specified by:
addin interfacePNodeI- Overrides:
addin classAbstractPNode- Parameters:
node- to add- Returns:
- node representing the sum
- Throws:
ParseException- on error
-
sub
Description copied from class:AbstractPNodeReturns the difference between this node and argument- Specified by:
subin interfacePNodeI- Overrides:
subin classAbstractPNode- Parameters:
node- to subtract- Returns:
- node representing the difference
- Throws:
ParseException- on error
-
equalsPNode
Description copied from interface:PNodeITrue is nodes represent the same parse trees- Specified by:
equalsPNodein interfacePNodeI- Overrides:
equalsPNodein classAbstractPNode
-
hashCode
public int hashCode() -
compareTo
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 interfaceComparable<PNodeI>- Specified by:
compareToin interfacePNodeI- Overrides:
compareToin classAbstractPNode- Returns:
- -1,0,1
-
toString
-
toString
Description copied from interface:PNodeIProduces a string representation of the argument. -
toNode
Description copied from interface:PNodeIConverts the node to standard Jep format.- Throws:
ParseException
-
toCompactNode
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
Description copied from interface:PNodeIcomplete expansion. (1+x)^2 --> 1+2*x+x^2- Throws:
ParseException
-
getCoeff
- Returns:
- Returns the coefficient.
-
getNVars
public int getNVars()- Returns:
- return the number of variables.
-
getVar
Returns the i-th variable- Parameters:
i-- Returns:
- PNodeI for the i-th variable in product
-
getPower
Returns the i-th power- Parameters:
i-- Returns:
- PNodeI for the power of the i-th variable in product
-
convertToPolyArray
Description copied from interface:PNodeIInternal method for extracting coefficients- Parameters:
var- variable namepolyArray- results added to this map- Throws:
ParseException
-
substitute
Description copied from interface:PNodeISubstitute all occurrence of variable with its replacement.- Parameters:
var- the variablesub- the replacement- Returns:
- Throws:
ParseException
-
totalDegree
The total degree of the monomial. The sum of degrees of each term- Returns:
- the total degree
- Throws:
ParseException- if any power is not constant
-