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 PNodeI
add(PNodeI node)
Adds a node to this one.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^2void
convertToPolyArray(java.lang.String var, java.util.Map<java.lang.Integer,PNodeI> polyArray)
Internal method for extracting coefficientsPNodeI
div(PNodeI node)
Divides this by the argument.boolean
equalsPNode(PNodeI node)
True is nodes represent the same parse treesPNodeI
expand()
complete expansion. (1+x)^2 --> 1+2*x+x^2PConstant
getCoeff()
int
getNVars()
PNodeI
getPower(int i)
Returns the i-th powerPNodeI
getVar(int i)
Returns the i-th variableint
hashCode()
PNodeI
invert()
inverts node i.e. 1/xPNodeI
mul(PNodeI node)
Multiplies this by the argument.PNodeI
negate()
negates node i.e.PNodeI
pow(PNodeI pow)
Raise this to the argument.PNodeI
sub(PNodeI node)
Subtracts the argument from this.Node
toCompactNode()
Converts to a more efficient Jep representation.MutableMonomial
toMutiableMonomial()
Node
toNode()
Converts the node to standard Jep format.java.lang.String
toString()
Produces a string representation of the argument.static PNodeI
valueOf(PolynomialCreator pc, PConstant c, PNodeI v)
static PNodeI
valueOf(PolynomialCreator pc, PConstant coefficient, PNodeI[] terms, PNodeI[] pows)
static PNodeI
valueOf(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:PNodeI
Multiplies this by the argument.- Specified by:
mul
in interfacePNodeI
- Overrides:
mul
in classAbstractPNode
- Throws:
ParseException
-
div
public PNodeI div(PNodeI node) throws ParseException
Description copied from interface:PNodeI
Divides this by the argument.- Specified by:
div
in interfacePNodeI
- Overrides:
div
in classAbstractPNode
- Throws:
ParseException
-
pow
public PNodeI pow(PNodeI pow) throws ParseException
Description copied from interface:PNodeI
Raise this to the argument.- Specified by:
pow
in interfacePNodeI
- Overrides:
pow
in classAbstractPNode
- Throws:
ParseException
-
negate
public PNodeI negate() throws ParseException
Description copied from interface:PNodeI
negates node i.e. -x- Throws:
ParseException
-
invert
public PNodeI invert() throws ParseException
Description copied from interface:PNodeI
inverts node i.e. 1/x- Specified by:
invert
in interfacePNodeI
- Overrides:
invert
in classAbstractPNode
- Throws:
ParseException
-
add
public PNodeI add(PNodeI node) throws ParseException
Description copied from interface:PNodeI
Adds a node to this one.- Specified by:
add
in interfacePNodeI
- Overrides:
add
in classAbstractPNode
- Throws:
ParseException
-
sub
public PNodeI sub(PNodeI node) throws ParseException
Description copied from interface:PNodeI
Subtracts the argument from this.- Specified by:
sub
in interfacePNodeI
- Overrides:
sub
in classAbstractPNode
- Throws:
ParseException
-
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(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:
compareTo
in interfacejava.lang.Comparable<PNodeI>
- Specified by:
compareTo
in interfacePNodeI
- Overrides:
compareTo
in classAbstractPNode
- Returns:
- -1,0,1
-
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
-
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 ParseException
Description copied from interface:PNodeI
Internal method for extracting coefficients- Parameters:
var
- variable namepolyArray
- results added to this map- Throws:
ParseException
-
-