Class SymbolicPolynomialRing
- java.lang.Object
-
- org.matheclipse.core.polynomials.symbolicexponent.SymbolicPolynomialRing
-
- All Implemented Interfaces:
edu.jas.structure.AbelianGroupFactory<SymbolicPolynomial>
,edu.jas.structure.ElemFactory<SymbolicPolynomial>
,edu.jas.structure.MonoidFactory<SymbolicPolynomial>
,edu.jas.structure.RingFactory<SymbolicPolynomial>
,Serializable
public class SymbolicPolynomialRing extends Object implements edu.jas.structure.RingFactory<SymbolicPolynomial>
GenPolynomialRing generic polynomial factory implementing ExprRingFactory; Factory for n-variate ordered polynomials over C with JavaIExpr
exponents. Almost immutable object, except variable names.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description ExprRingFactory
coFac
The factory for the coefficients.ExpVectorSymbolic
evzero
The constant exponent vector 0 for this ring.protected int
isField
Indicator if this ring is a field.int
nvar
The number of variables.SymbolicPolynomial
ONE
The constant polynomial 1 for this ring.protected boolean
partial
True for partially reversed variables.protected static ThreadLocalRandom
random
A default random sequence generator.SymbolicTermOrder
tord
The term order.protected IAST
vars
The names of the variables.SymbolicPolynomial
ZERO
The constant polyl 0 for this ring.
-
Constructor Summary
Constructors Constructor Description SymbolicPolynomialRing(IAST listOfVariables)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(IAST listOfVariables, SymbolicTermOrder t)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(ISymbol symbol)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(ISymbol symbol, SymbolicTermOrder t)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables, int n, SymbolicTermOrder t, boolean numericFunction)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables, SymbolicTermOrder t)
The constructor creates a polynomial factory object.SymbolicPolynomialRing(ExprRingFactory cf, SymbolicPolynomialRing o)
The constructor creates a polynomial factory object with the the same term order, number of variables and variable names as the given polynomial factory, only the coefficient factories differ.SymbolicPolynomialRing(SymbolicPolynomialRing o, SymbolicTermOrder to)
The constructor creates a polynomial factory object with the the same coefficient factory, number of variables and variable names as the given polynomial factory, only the term order differs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BigInteger
characteristic()
Characteristic of this ring.SymbolicPolynomialRing
copy()
Copy this factory.SymbolicPolynomial
copy(SymbolicPolynomial c)
Copy polynomial c.SymbolicPolynomial
create(IExpr exprPoly)
Create aPolynomial
from the givenexprPoly
.SymbolicPolynomial
create(IExpr exprPoly, boolean coefficient, boolean checkNegativeExponents, boolean coefficientListMode)
Create aPolynomial
from the givenexprPoly
.static Map<IExpr,IExpr>
create(IExpr exprPoly, IExpr x, Map<IExpr,IExpr> coefficientMap, IASTAppendable restList)
Create the coefficients of the (univariate) polynomial incoefficientMap
and append non-polynomial terms torestList
static Map<IExpr,IExpr>
createTimes(IAST ast, IExpr x, Map<IExpr,IExpr> coefficientMap, IASTAppendable restList)
boolean
equals(Object other)
Comparison with any other object.SymbolicPolynomialRing
extend(IAST vn)
Extend variables.SymbolicPolynomial
fromInteger(long a)
Get a (constant) GenPolynomial<C> element from a long value.SymbolicPolynomial
fromInteger(BigInteger a)
Get a (constant) GenPolynomial<C> element from a BigInteger value.List<SymbolicPolynomial>
generators()
Get a list of the generating elements.List<SymbolicPolynomial>
generators(int modv)
Get a list of the generating elements excluding the module variables.org.matheclipse.core.polynomials.symbolicexponent.SymbolicPolynomialRing.SymbolicPolynomialComparator
getComparator()
Get PolynomialComparator.org.matheclipse.core.polynomials.symbolicexponent.SymbolicPolynomialRing.SymbolicPolynomialComparator
getComparator(boolean rev)
Get PolynomialComparator.List<SymbolicPolynomial>
getGenerators()
Get the generating elements excluding the generators for the coefficient ring.SymbolicPolynomial
getOne()
Get the one element.SymbolicPolynomial
getONE()
IExpr
getONECoefficient()
Get the one element from the coefficients.IAST
getVars()
Get the variable names.SymbolicPolynomial
getZero()
Get the zero element.SymbolicPolynomial
getZERO()
IExpr
getZEROCoefficient()
Get the zero element from the coefficients.int
hashCode()
Hash code for this polynomial ring.boolean
isAssociative()
Query if this ring is associative.boolean
isCommutative()
Query if this ring is commutative.boolean
isField()
Query if this ring is a field.boolean
isFinite()
Is this structure finite or infinite.boolean
isPolynomial(IExpr expression)
Create aPolynomial
from the givenexprPoly
.boolean
isPolynomial(IExpr expression, boolean coefficient)
Create aPolynomial
from the givenexprPoly
.Iterator<SymbolicPolynomial>
iterator()
Get a GenPolynomial iterator.SymbolicPolynomial
parse(Reader r)
SymbolicPolynomial
parse(String s)
static String[]
permuteVars(List<Integer> P, String[] vars)
Permute variable names.SymbolicPolynomial
random(int n)
SymbolicPolynomial
random(int n, Random random)
IAST
setVars(IAST v)
Set the variable names.String
toScript()
Get a scripting compatible string representation.String
toScript(ExpVectorSymbolic e)
Get a scripting compatible string representation of an ExpVectorLong of this ring.String
toString()
Get the String representation.SymbolicPolynomial
univariate(int i)
Generate univariate polynomial in a given variable.SymbolicPolynomial
univariate(int modv, int i, IExpr e)
Generate univariate polynomial in a given variable with given exponent.SymbolicPolynomial
univariate(int i, IExpr e)
Generate univariate polynomial in a given variable with given exponent.List<? extends SymbolicPolynomial>
univariateList()
Generate list of univariate polynomials in all variables.List<? extends SymbolicPolynomial>
univariateList(int modv)
Generate list of univariate polynomials in all variables.List<? extends SymbolicPolynomial>
univariateList(int modv, IExpr e)
Generate list of univariate polynomials in all variables with given exponent.SymbolicPolynomial
valueOf(IExpr a)
Get a (constant) GenPolynomial<C> element from a coefficient value.SymbolicPolynomial
valueOf(IExpr a, ExpVectorSymbolic e)
Get a GenPolynomial<C> element from a coeffcient and an exponent vector.SymbolicPolynomial
valueOf(ExpVectorSymbolic e)
Get a GenPolynomial<C> element from an exponent vector.String
varsToString()
Get a String representation of the variable names.
-
-
-
Field Detail
-
coFac
public final ExprRingFactory coFac
The factory for the coefficients.
-
nvar
public final int nvar
The number of variables.
-
tord
public final SymbolicTermOrder tord
The term order.
-
partial
protected boolean partial
True for partially reversed variables.
-
vars
protected IAST vars
The names of the variables. This value can be modified.
-
ZERO
public final SymbolicPolynomial ZERO
The constant polyl 0 for this ring.
-
ONE
public final SymbolicPolynomial ONE
The constant polynomial 1 for this ring.
-
evzero
public final ExpVectorSymbolic evzero
The constant exponent vector 0 for this ring.
-
random
protected static final ThreadLocalRandom random
A default random sequence generator.
-
isField
protected int isField
Indicator if this ring is a field.
-
-
Constructor Detail
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(IAST listOfVariables)
The constructor creates a polynomial factory object.- Parameters:
listOfVariables
- names for the variables.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(IAST listOfVariables, SymbolicTermOrder t)
The constructor creates a polynomial factory object.- Parameters:
listOfVariables
- names for the variables.t
- a term order.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(ISymbol symbol)
The constructor creates a polynomial factory object.- Parameters:
symbol
- name of a variable.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(ISymbol symbol, SymbolicTermOrder t)
The constructor creates a polynomial factory object.- Parameters:
symbol
- name of a variable.t
- a term order.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables)
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.listOfVariables
- names for the variables.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables, SymbolicTermOrder t)
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.listOfVariables
- names for the variables.t
- a term order.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables, int n, SymbolicTermOrder t, boolean numericFunction)
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.listOfVariables
- names for the variables.n
- number of variables.t
- a term order.numericFunction
-
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(ExprRingFactory cf, SymbolicPolynomialRing o)
The constructor creates a polynomial factory object with the the same term order, number of variables and variable names as the given polynomial factory, only the coefficient factories differ.- Parameters:
cf
- factory for coefficients of type C.o
- other polynomial ring.
-
SymbolicPolynomialRing
public SymbolicPolynomialRing(SymbolicPolynomialRing o, SymbolicTermOrder to)
The constructor creates a polynomial factory object with the the same coefficient factory, number of variables and variable names as the given polynomial factory, only the term order differs.- Parameters:
to
- term order.o
- other polynomial ring.
-
-
Method Detail
-
copy
public SymbolicPolynomialRing copy()
Copy this factory.- Returns:
- a clone of this.
-
create
public SymbolicPolynomial create(IExpr exprPoly) throws ArithmeticException, ClassCastException
Create aPolynomial
from the givenexprPoly
.- Parameters:
exprPoly
- the polynomial expression- Returns:
- Throws:
ArithmeticException
ClassCastException
-
create
public SymbolicPolynomial create(IExpr exprPoly, boolean coefficient, boolean checkNegativeExponents, boolean coefficientListMode) throws ArithmeticException, ClassCastException
Create aPolynomial
from the givenexprPoly
.- Parameters:
exprPoly
- the polynomial expressioncoefficient
- set totrue
if called by theCoefficient()
functioncheckNegativeExponents
- iftrue
don't allow negative exponents and throw an ArithmeticExceptioncoefficientListMode
- if in coefficient list mode don't collect negativePower()
exponents- Returns:
- Throws:
ArithmeticException
ClassCastException
-
create
public static Map<IExpr,IExpr> create(IExpr exprPoly, IExpr x, Map<IExpr,IExpr> coefficientMap, IASTAppendable restList) throws ArithmeticException
Create the coefficients of the (univariate) polynomial incoefficientMap
and append non-polynomial terms torestList
- Parameters:
exprPoly
- the polynomial expressionx
- the variable xcoefficientMap
- the map of exponents to the associated coefficientsrestList
- the terms which are non-polynomial- Returns:
- Throws:
ArithmeticException
-
createTimes
public static Map<IExpr,IExpr> createTimes(IAST ast, IExpr x, Map<IExpr,IExpr> coefficientMap, IASTAppendable restList)
-
isPolynomial
public boolean isPolynomial(IExpr expression) throws ArithmeticException, ClassCastException
Create aPolynomial
from the givenexprPoly
.- Parameters:
expression
- the expression which should be checked if it's a polynomial- Returns:
true
if the given expression is a polynomial- Throws:
ArithmeticException
ClassCastException
-
isPolynomial
public boolean isPolynomial(IExpr expression, boolean coefficient) throws ArithmeticException, ClassCastException
Create aPolynomial
from the givenexprPoly
.- Parameters:
expression
- the expression which should be checked if it's a polynomialcoefficient
- set totrue
if called by theCoefficient()
function- Returns:
true
if the given expression is a polynomial- Throws:
ArithmeticException
ClassCastException
-
toString
public String toString()
Get the String representation.- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
toScript
public String toScript()
Get a scripting compatible string representation.- Specified by:
toScript
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
- Returns:
- script compatible representation for this Element.
- See Also:
Element.toScript()
-
toScript
public String toScript(ExpVectorSymbolic e)
Get a scripting compatible string representation of an ExpVectorLong of this ring.- Parameters:
e
- exponent vector- Returns:
- script compatible representation for the ExpVectorLong.
-
equals
public boolean equals(Object other)
Comparison with any other object.- Overrides:
equals
in classObject
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Hash code for this polynomial ring.- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
getVars
public IAST getVars()
Get the variable names.- Returns:
- vars.
-
varsToString
public String varsToString()
Get a String representation of the variable names.- Returns:
- names seperated by commas.
-
getZEROCoefficient
public IExpr getZEROCoefficient()
Get the zero element from the coefficients.- Returns:
- 0 as C.
-
getONECoefficient
public IExpr getONECoefficient()
Get the one element from the coefficients.- Returns:
- 1 as C.
-
getZero
public SymbolicPolynomial getZero()
Get the zero element.- Returns:
- 0 as GenPolynomial.
-
getOne
public SymbolicPolynomial getOne()
Get the one element.- Returns:
- 1 as GenPolynomial.
-
isCommutative
public boolean isCommutative()
Query if this ring is commutative.- Specified by:
isCommutative
in interfaceedu.jas.structure.MonoidFactory<SymbolicPolynomial>
- Returns:
- true if this ring is commutative, else false.
-
isAssociative
public boolean isAssociative()
Query if this ring is associative.- Specified by:
isAssociative
in interfaceedu.jas.structure.MonoidFactory<SymbolicPolynomial>
- Returns:
- true if this ring is associative, else false.
-
isField
public boolean isField()
Query if this ring is a field.- Specified by:
isField
in interfaceedu.jas.structure.RingFactory<SymbolicPolynomial>
- Returns:
- false.
-
characteristic
public BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristic
in interfaceedu.jas.structure.RingFactory<SymbolicPolynomial>
- Returns:
- characteristic of this ring.
-
valueOf
public SymbolicPolynomial valueOf(IExpr a)
Get a (constant) GenPolynomial<C> element from a coefficient value.- Parameters:
a
- coefficient.- Returns:
- a GenPolynomial<C>.
-
valueOf
public SymbolicPolynomial valueOf(ExpVectorSymbolic e)
Get a GenPolynomial<C> element from an exponent vector.- Parameters:
e
- exponent vector.- Returns:
- a GenPolynomial<C>.
-
valueOf
public SymbolicPolynomial valueOf(IExpr a, ExpVectorSymbolic e)
Get a GenPolynomial<C> element from a coeffcient and an exponent vector.- Parameters:
a
- coefficient.e
- exponent vector.- Returns:
- a GenPolynomial<C>.
-
fromInteger
public SymbolicPolynomial fromInteger(long a)
Get a (constant) GenPolynomial<C> element from a long value.- Specified by:
fromInteger
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
- Parameters:
a
- long.- Returns:
- a GenPolynomial<C>.
-
fromInteger
public SymbolicPolynomial fromInteger(BigInteger a)
Get a (constant) GenPolynomial<C> element from a BigInteger value.- Specified by:
fromInteger
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
- Parameters:
a
- BigInteger.- Returns:
- a GenPolynomial<C>.
-
copy
public SymbolicPolynomial copy(SymbolicPolynomial c)
Copy polynomial c.- Specified by:
copy
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
- Parameters:
c
-- Returns:
- a copy of c.
-
univariate
public SymbolicPolynomial univariate(int i)
Generate univariate polynomial in a given variable.- Parameters:
i
- the index of the variable.- Returns:
- X_i as univariate polynomial.
-
univariate
public SymbolicPolynomial univariate(int i, IExpr e)
Generate univariate polynomial in a given variable with given exponent.- Parameters:
i
- the index of the variable.e
- the exponent of the variable.- Returns:
- X_i^e as univariate polynomial.
-
univariate
public SymbolicPolynomial univariate(int modv, int i, IExpr e)
Generate univariate polynomial in a given variable with given exponent.- Parameters:
modv
- number of module variables.i
- the index of the variable.e
- the exponent of the variable.- Returns:
- X_i^e as univariate polynomial.
-
getGenerators
public List<SymbolicPolynomial> getGenerators()
Get the generating elements excluding the generators for the coefficient ring.- Returns:
- a list of generating elements for this ring.
-
generators
public List<SymbolicPolynomial> generators()
Get a list of the generating elements.- Specified by:
generators
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
- Returns:
- list of generators for the algebraic structure.
- See Also:
ElemFactory.generators()
-
generators
public List<SymbolicPolynomial> generators(int modv)
Get a list of the generating elements excluding the module variables.- Parameters:
modv
- number of module variables- Returns:
- list of generators for the polynomial ring.
-
isFinite
public boolean isFinite()
Is this structure finite or infinite.- Specified by:
isFinite
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
- Returns:
- true if this structure is finite, else false.
- See Also:
ElemFactory.isFinite()
-
univariateList
public List<? extends SymbolicPolynomial> univariateList()
Generate list of univariate polynomials in all variables.- Returns:
- List(X_1,...,X_n) a list of univariate polynomials.
-
univariateList
public List<? extends SymbolicPolynomial> univariateList(int modv)
Generate list of univariate polynomials in all variables.- Parameters:
modv
- number of module variables.- Returns:
- List(X_1,...,X_n) a list of univariate polynomials.
-
univariateList
public List<? extends SymbolicPolynomial> univariateList(int modv, IExpr e)
Generate list of univariate polynomials in all variables with given exponent.- Parameters:
modv
- number of module variables.e
- the exponent of the variables.- Returns:
- List(X_1^e,...,X_n^e) a list of univariate polynomials.
-
extend
public SymbolicPolynomialRing extend(IAST vn)
Extend variables. Used e.g. in module embedding. Extend number of variables by length(vn).- Parameters:
vn
- names for extended variables.- Returns:
- extended polynomial ring factory.
-
getComparator
public org.matheclipse.core.polynomials.symbolicexponent.SymbolicPolynomialRing.SymbolicPolynomialComparator getComparator()
Get PolynomialComparator.- Returns:
- polynomial comparator.
-
getComparator
public org.matheclipse.core.polynomials.symbolicexponent.SymbolicPolynomialRing.SymbolicPolynomialComparator getComparator(boolean rev)
Get PolynomialComparator.- Parameters:
rev
- for reverse comparator.- Returns:
- polynomial comparator.
-
permuteVars
public static String[] permuteVars(List<Integer> P, String[] vars)
Permute variable names.- Parameters:
vars
- variable names.P
- permutation.- Returns:
- P(vars).
-
iterator
public Iterator<SymbolicPolynomial> iterator()
Get a GenPolynomial iterator.- Returns:
- an iterator over all polynomials.
-
getZERO
public SymbolicPolynomial getZERO()
- Specified by:
getZERO
in interfaceedu.jas.structure.AbelianGroupFactory<SymbolicPolynomial>
-
random
public SymbolicPolynomial random(int n)
- Specified by:
random
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
-
random
public SymbolicPolynomial random(int n, Random random)
- Specified by:
random
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
-
parse
public SymbolicPolynomial parse(String s)
- Specified by:
parse
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
-
parse
public SymbolicPolynomial parse(Reader r)
- Specified by:
parse
in interfaceedu.jas.structure.ElemFactory<SymbolicPolynomial>
-
getONE
public SymbolicPolynomial getONE()
- Specified by:
getONE
in interfaceedu.jas.structure.MonoidFactory<SymbolicPolynomial>
-
-