modelparameters.sympy.polys.domains package
modelparameters.sympy.polys.domains.algebraicfield module
Implementation of AlgebraicField
class.
-
class modelparameters.sympy.polys.domains.algebraicfield.AlgebraicField(dom, *ext)[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
A class for representing algebraic number fields.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. mathbb{Q}(alpha, ldots).
-
denom(a)[source]
Returns denominator of a
.
-
dtype
alias of ANP
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf
object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
is_Algebraic = True
-
is_AlgebraicField = True
-
is_Numerical = True
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_positive(a)[source]
Returns True if a
is positive.
-
new(element)[source]
-
numer(a)[source]
Returns numerator of a
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
modelparameters.sympy.polys.domains.characteristiczero module
Implementaton of CharacteristicZero
class.
-
class modelparameters.sympy.polys.domains.characteristiczero.CharacteristicZero[source]
Bases: Domain
Domain that has infinite number of elements.
-
characteristic()[source]
Return the characteristic of this domain.
-
has_CharacteristicZero = True
modelparameters.sympy.polys.domains.complexfield module
Implementation of ComplexField
class.
-
class modelparameters.sympy.polys.domains.complexfield.ComplexField(prec=53, dps=None, tol=None)[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
Complex numbers up to the given precision.
-
almosteq(a, b, tolerance=None)[source]
Check if a
and b
are almost equal.
-
property dps
-
from_ComplexField(element, base)[source]
Convert a complex element to dtype
.
-
from_QQ_gmpy(element, base)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(element, base)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(element, base)[source]
Convert a real element object to dtype
.
-
from_ZZ_gmpy(element, base)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(element, base)[source]
Convert a Python int
object to dtype
.
-
from_sympy(expr)[source]
Convert SymPy’s number to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
-
get_exact()[source]
Returns an exact domain associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
property has_default_precision
-
is_CC = True
-
is_ComplexField = True
-
is_Exact = False
-
is_Numerical = True
-
lcm(a, b)[source]
Returns LCM of a
and b
.
-
property precision
-
rep = 'CC'
-
to_sympy(element)[source]
Convert element
to SymPy number.
-
property tolerance
modelparameters.sympy.polys.domains.compositedomain module
Implementation of CompositeDomain
class.
-
class modelparameters.sympy.polys.domains.compositedomain.CompositeDomain[source]
Bases: Domain
Base class for composite domains, e.g. ZZ[x], ZZ(X).
-
domain = None
-
gens = None
-
inject(*symbols)[source]
Inject generators into this domain.
-
is_Composite = True
-
ngens = None
-
symbols = None
modelparameters.sympy.polys.domains.domain module
Implementation of Domain
class.
-
class modelparameters.sympy.polys.domains.domain.Domain[source]
Bases: object
Represents an abstract domain.
-
abs(a)[source]
Absolute value of a
, implies __abs__
.
-
add(a, b)[source]
Sum of a
and b
, implies __add__
.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. K(alpha, ldots).
-
alias = None
-
almosteq(a, b, tolerance=None)[source]
Check if a
and b
are almost equal.
-
characteristic()[source]
Return the characteristic of this domain.
-
cofactors(a, b)[source]
Returns GCD and cofactors of a
and b
.
-
convert(element, base=None)[source]
Convert element
to self.dtype
.
-
convert_from(element, base)[source]
Convert element
to self.dtype
given the base domain.
-
denom(a)[source]
Returns denominator of a
.
-
div(a, b)[source]
Division of a
and b
, implies something.
-
dtype = None
-
evalf(a, prec=None, **options)[source]
Returns numerical approximation of a
.
-
exquo(a, b)[source]
Exact quotient of a
and b
, implies something.
-
frac_field(*symbols, **kwargs)[source]
Returns a fraction field, i.e. K(X).
-
from_AlgebraicField(a, K0)[source]
Convert an algebraic number to dtype
.
-
from_ComplexField(a, K0)[source]
Convert a complex element to dtype
.
-
from_ExpressionDomain(a, K0)[source]
Convert a EX
object to dtype
.
-
from_FF_gmpy(a, K0)[source]
Convert ModularInteger(mpz)
to dtype
.
-
from_FF_python(a, K0)[source]
Convert ModularInteger(int)
to dtype
.
-
from_FractionField(a, K0)[source]
Convert a rational function to dtype
.
-
from_GeneralizedPolynomialRing(a, K0)[source]
-
from_GlobalPolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a real element object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert a SymPy object to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
-
gcdex(a, b)[source]
Extended GCD of a
and b
.
-
get_exact()[source]
Returns an exact domain associated with self
.
-
get_field()[source]
Returns a field associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
half_gcdex(a, b)[source]
Half extended GCD of a
and b
.
-
has_CharacteristicZero = False
-
property has_Field
-
property has_Ring
-
has_assoc_Field = False
-
has_assoc_Ring = False
-
imag(a)[source]
-
inject(*symbols)[source]
Inject generators into this domain.
-
invert(a, b)[source]
Returns inversion of a mod b
, implies something.
-
is_Algebraic = False
-
is_AlgebraicField = False
-
is_CC = False
-
is_ComplexField = False
-
is_Composite = False
-
is_EX = False
-
is_Exact = True
-
is_FF = False
-
is_Field = False
-
is_FiniteField = False
-
is_Frac = False
-
is_FractionField = False
-
is_IntegerRing = False
-
is_Numerical = False
-
is_PID = False
-
is_Poly = False
-
is_PolynomialRing = False
-
is_QQ = False
-
is_RR = False
-
is_RationalField = False
-
is_RealField = False
-
is_Ring = False
-
is_Simple = False
-
is_SymbolicDomain = False
-
is_ZZ = False
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_one(a)[source]
Returns True if a
is one.
-
is_positive(a)[source]
Returns True if a
is positive.
-
is_zero(a)[source]
Returns True if a
is zero.
-
lcm(a, b)[source]
Returns LCM of a
and b
.
-
log(a, b)[source]
Returns b-base logarithm of a
.
-
map(seq)[source]
Rersively apply self
to all elements of seq
.
-
mul(a, b)[source]
Product of a
and b
, implies __mul__
.
-
n(a, prec=None, **options)
Returns numerical approximation of a
.
-
neg(a)[source]
Returns a
negated, implies __neg__
.
-
new(*args)[source]
-
normal(*args)[source]
-
numer(a)[source]
Returns numerator of a
.
-
of_type(element)[source]
Check if a
is of type dtype
.
-
old_frac_field(*symbols, **kwargs)[source]
Returns a fraction field, i.e. K(X).
-
old_poly_ring(*symbols, **kwargs)[source]
Returns a polynomial ring, i.e. K[X].
-
one = None
-
poly_ring(*symbols, **kwargs)[source]
Returns a polynomial ring, i.e. K[X].
-
pos(a)[source]
Returns a
positive, implies __pos__
.
-
pow(a, b)[source]
Raise a
to power b
, implies __pow__
.
-
quo(a, b)[source]
Quotient of a
and b
, implies something.
-
real(a)[source]
-
rem(a, b)[source]
Remainder of a
and b
, implies __mod__
.
-
rep = None
-
revert(a)[source]
Returns a**(-1)
if possible.
-
sqrt(a)[source]
Returns square root of a
.
-
sub(a, b)[source]
Difference of a
and b
, implies __sub__
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
property tp
-
unify(K1, symbols=None)[source]
Construct a minimal domain that contains elements of K0
and K1
.
Known domains (from smallest to largest):
GF(p)
ZZ
QQ
RR(prec, tol)
CC(prec, tol)
ALG(a, b, c)
K[x, y, z]
K(x, y, z)
EX
-
unify_with_symbols(K1, symbols)[source]
-
zero = None
modelparameters.sympy.polys.domains.domainelement module
Trait for implementing domain elements.
-
class modelparameters.sympy.polys.domains.domainelement.DomainElement[source]
Bases: object
Represents an element of a domain.
Mix in this trait into a class which instances should be recognized as
elements of a domain. Method parent()
gives that domain.
-
parent()[source]
modelparameters.sympy.polys.domains.expressiondomain module
Implementation of ExpressionDomain
class.
-
class modelparameters.sympy.polys.domains.expressiondomain.ExpressionDomain[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
A class for arbitrary expressions.
-
class Expression(ex)[source]
Bases: PicklableWithSlots
An arbitrary expression.
-
as_expr()[source]
-
denom()[source]
-
ex
-
gcd(g)[source]
-
lcm(g)[source]
-
numer()[source]
-
simplify(ex)[source]
-
denom(a)[source]
Returns denominator of a
.
-
dtype
alias of Expression
-
from_ExpressionDomain(a, K0)[source]
Convert a EX
object to dtype
.
-
from_FractionField(a, K0)[source]
Convert a DMF
object to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a DMP
object to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf
object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
This definition of GCD over fields allows to clear denominators
in primitive().
>>> from ..domains import QQ
>>> from ... import S, gcd, primitive
>>> from ...abc import x
>>> QQ.gcd(QQ(2, 3), QQ(4, 9))
2/9
>>> gcd(S(2)/3, S(4)/9)
2/9
>>> primitive(2*x/3 + S(4)/9)
(2/9, 3*x + 2)
-
get_field()[source]
Returns a field associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
is_EX = True
-
is_SymbolicDomain = True
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_positive(a)[source]
Returns True if a
is positive.
-
lcm(a, b)[source]
Returns LCM of a
and b
.
>>> from ..domains import QQ
>>> from ... import S, lcm
>>> QQ.lcm(QQ(2, 3), QQ(4, 9))
4/3
>>> lcm(S(2)/3, S(4)/9)
4/3
-
numer(a)[source]
Returns numerator of a
.
-
one = EX(1)
-
rep = 'EX'
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
zero = EX(0)
modelparameters.sympy.polys.domains.field module
Implementation of Field
class.
-
class modelparameters.sympy.polys.domains.field.Field[source]
Bases: Ring
Represents a field domain.
-
div(a, b)[source]
Division of a
and b
, implies __div__
.
-
exquo(a, b)[source]
Exact quotient of a
and b
, implies __div__
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
This definition of GCD over fields allows to clear denominators
in primitive().
>>> from ..domains import QQ
>>> from ... import S, gcd, primitive
>>> from ...abc import x
>>> QQ.gcd(QQ(2, 3), QQ(4, 9))
2/9
>>> gcd(S(2)/3, S(4)/9)
2/9
>>> primitive(2*x/3 + S(4)/9)
(2/9, 3*x + 2)
-
get_field()[source]
Returns a field associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
is_Field = True
-
is_PID = True
-
lcm(a, b)[source]
Returns LCM of a
and b
.
>>> from ..domains import QQ
>>> from ... import S, lcm
>>> QQ.lcm(QQ(2, 3), QQ(4, 9))
4/3
>>> lcm(S(2)/3, S(4)/9)
4/3
-
quo(a, b)[source]
Quotient of a
and b
, implies __div__
.
-
rem(a, b)[source]
Remainder of a
and b
, implies nothing.
-
revert(a)[source]
Returns a**(-1)
if possible.
modelparameters.sympy.polys.domains.finitefield module
Implementation of FiniteField
class.
-
class modelparameters.sympy.polys.domains.finitefield.FiniteField(mod, dom=None, symmetric=True)[source]
Bases: Field
, SimpleDomain
General class for finite fields.
-
characteristic()[source]
Return the characteristic of this domain.
-
dom = None
-
from_FF_gmpy(a, K0=None)[source]
Convert ModularInteger(mpz)
to dtype
.
-
from_FF_python(a, K0=None)[source]
Convert ModularInteger(int)
to dtype
.
-
from_QQ_gmpy(a, K0=None)[source]
Convert GMPY’s mpq
to dtype
.
-
from_QQ_python(a, K0=None)[source]
Convert Python’s Fraction
to dtype
.
-
from_RealField(a, K0)[source]
Convert mpmath’s mpf
to dtype
.
-
from_ZZ_gmpy(a, K0=None)[source]
Convert GMPY’s mpz
to dtype
.
-
from_ZZ_python(a, K0=None)[source]
Convert Python’s int
to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s Integer to SymPy’s Integer
.
-
get_field()[source]
Returns a field associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
is_FF = True
-
is_FiniteField = True
-
is_Numerical = True
-
mod = None
-
rep = 'FF'
-
to_sympy(a)[source]
Convert a
to a SymPy object.
modelparameters.sympy.polys.domains.fractionfield module
Implementation of FractionField
class.
-
class modelparameters.sympy.polys.domains.fractionfield.FractionField(domain_or_field, symbols=None, order=None)[source]
Bases: Field
, CompositeDomain
A class for representing multivariate rational function fields.
-
denom(a)[source]
Returns denominator of a
.
-
factorial(a)[source]
Returns factorial of a.
-
from_AlgebraicField(a, K0)[source]
Convert an algebraic number to dtype
.
-
from_FractionField(a, K0)[source]
Convert a rational function to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype.
-
get_ring()[source]
Returns a field associated with self.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Frac = True
-
is_FractionField = True
-
is_negative(a)[source]
Returns True if LC(a) is negative.
-
is_nonnegative(a)[source]
Returns True if LC(a) is non-negative.
-
is_nonpositive(a)[source]
Returns True if LC(a) is non-positive.
-
is_positive(a)[source]
Returns True if LC(a) is positive.
-
new(element)[source]
-
numer(a)[source]
Returns numerator of a
.
-
property one
-
property order
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
property zero
modelparameters.sympy.polys.domains.gmpyfinitefield module
Implementation of GMPYFiniteField
class.
-
class modelparameters.sympy.polys.domains.gmpyfinitefield.GMPYFiniteField(mod, symmetric=True)[source]
Bases: FiniteField
Finite field based on GMPY integers.
-
alias = 'FF_gmpy'
modelparameters.sympy.polys.domains.gmpyintegerring module
Implementaton of GMPYIntegerRing
class.
-
class modelparameters.sympy.polys.domains.gmpyintegerring.GMPYIntegerRing[source]
Bases: IntegerRing
Integer ring based on GMPY’s mpz
type.
-
alias = 'ZZ_gmpy'
-
dtype
alias of GMPYInteger
-
factorial(a)[source]
Compute factorial of a
.
-
from_FF_gmpy(a, K0)[source]
Convert ModularInteger(mpz)
to GMPY’s mpz
.
-
from_FF_python(a, K0)[source]
Convert ModularInteger(int)
to GMPY’s mpz
.
-
from_QQ_gmpy(a, K0)[source]
Convert GMPY mpq
to GMPY’s mpz
.
-
from_QQ_python(a, K0)[source]
Convert Python’s Fraction
to GMPY’s mpz
.
-
from_RealField(a, K0)[source]
Convert mpmath’s mpf
to GMPY’s mpz
.
-
from_ZZ_gmpy(a, K0)[source]
Convert GMPY’s mpz
to GMPY’s mpz
.
-
from_ZZ_python(a, K0)[source]
Convert Python’s int
to GMPY’s mpz
.
-
from_sympy(a)[source]
Convert SymPy’s Integer to dtype
.
-
gcd(a, b)[source]
Compute GCD of a
and b
.
-
gcdex(a, b)[source]
Compute extended GCD of a
and b
.
-
lcm(a, b)[source]
Compute LCM of a
and b
.
-
one = <modelparameters.sympy.polys.domains.groundtypes.GMPYInteger object>
-
sqrt(a)[source]
Compute square root of a
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
tp
alias of GMPYInteger
-
zero = <modelparameters.sympy.polys.domains.groundtypes.GMPYInteger object>
modelparameters.sympy.polys.domains.gmpyrationalfield module
Implementaton of GMPYRationalField
class.
-
class modelparameters.sympy.polys.domains.gmpyrationalfield.GMPYRationalField[source]
Bases: RationalField
Rational field based on GMPY mpq class.
-
alias = 'QQ_gmpy'
-
denom(a)[source]
Returns denominator of a.
-
div(a, b)[source]
Division of a and b, implies __div__.
-
dtype
alias of GMPYRational
-
exquo(a, b)[source]
Exact quotient of a and b, implies __div__.
-
factorial(a)[source]
Returns factorial of a.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s Integer to dtype.
-
get_ring()[source]
Returns ring associated with self
.
-
numer(a)[source]
Returns numerator of a.
-
one = <modelparameters.sympy.polys.domains.groundtypes.GMPYRational object>
-
quo(a, b)[source]
Quotient of a and b, implies __div__.
-
rem(a, b)[source]
Remainder of a and b, implies nothing.
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
tp
alias of GMPYRational
-
zero = <modelparameters.sympy.polys.domains.groundtypes.GMPYRational object>
modelparameters.sympy.polys.domains.groundtypes module
Ground types for various mathematical domains in SymPy.
modelparameters.sympy.polys.domains.integerring module
Implementation of IntegerRing
class.
-
class modelparameters.sympy.polys.domains.integerring.IntegerRing[source]
Bases: Ring
, CharacteristicZero
, SimpleDomain
General class for integer rings.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. mathbb{Q}(alpha, ldots).
-
from_AlgebraicField(a, K0)[source]
Convert a ANP
object to dtype
.
-
get_field()[source]
Returns a field associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_IntegerRing = True
-
is_Numerical = True
-
is_PID = True
-
is_ZZ = True
-
log(a, b)[source]
Returns b-base logarithm of a
.
-
rep = 'ZZ'
modelparameters.sympy.polys.domains.modularinteger module
Implementation of ModularInteger
class.
-
class modelparameters.sympy.polys.domains.modularinteger.ModularInteger(val)[source]
Bases: PicklableWithSlots
, DomainElement
A class representing a modular integer.
-
dom = None
-
invert()[source]
-
mod = None
-
parent()[source]
-
sym = None
-
to_int()[source]
-
val
modelparameters.sympy.polys.domains.mpelements module
Real and complex elements.
-
class modelparameters.sympy.polys.domains.mpelements.ComplexElement(real=0, imag=0)[source]
Bases: _mpc
, DomainElement
An element of a complex domain.
-
context = <modelparameters.sympy.polys.domains.mpelements.MPContext object>
-
parent()[source]
-
class modelparameters.sympy.polys.domains.mpelements.MPContext(prec=53, dps=None, tol=None)[source]
Bases: PythonMPContext
-
almosteq(s, t, rel_eps=None, abs_eps=None)[source]
-
make_tol()[source]
-
to_rational(s, limit=True)[source]
-
class modelparameters.sympy.polys.domains.mpelements.RealElement(val=(0, 0, 0, 0), **kwargs)[source]
Bases: _mpf
, DomainElement
An element of a real domain.
-
context = <modelparameters.sympy.polys.domains.mpelements.MPContext object>
-
parent()[source]
modelparameters.sympy.polys.domains.old_fractionfield module
Implementation of FractionField
class.
-
class modelparameters.sympy.polys.domains.old_fractionfield.FractionField(dom, *gens)[source]
Bases: Field
, CharacteristicZero
, CompositeDomain
A class for representing rational function fields.
-
denom(a)[source]
Returns denominator of a
.
-
dtype
alias of DMF
-
factorial(a)[source]
Returns factorial of a
.
-
frac_field(*gens)[source]
Returns a fraction field, i.e. K(X).
-
from_FractionField(a, K0)[source]
Convert a fraction field element to another fraction field.
Examples
>>> from ..polyclasses import DMF
>>> from ..domains import ZZ, QQ
>>> from ...abc import x
>>> f = DMF(([ZZ(1), ZZ(2)], [ZZ(1), ZZ(1)]), ZZ)
>>> QQx = QQ.old_frac_field(x)
>>> ZZx = ZZ.old_frac_field(x)
>>> QQx.from_FractionField(f, ZZx)
(x + 2)/(x + 1)
-
from_GlobalPolynomialRing(a, K0)[source]
Convert a DMF
object to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf
object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Frac = True
-
is_FractionField = True
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_positive(a)[source]
Returns True if a
is positive.
-
new(element)[source]
-
numer(a)[source]
Returns numerator of a
.
-
poly_ring(*gens)[source]
Returns a polynomial ring, i.e. K[X].
-
to_sympy(a)[source]
Convert a
to a SymPy object.
modelparameters.sympy.polys.domains.old_polynomialring module
Implementation of PolynomialRing
class.
-
class modelparameters.sympy.polys.domains.old_polynomialring.GlobalPolynomialRing(dom, *gens, **opts)[source]
Bases: PolynomialRingBase
A true polynomial ring, with objects DMP.
-
dtype
alias of DMP
-
from_FractionField(a, K0)[source]
Convert a DMF
object to DMP
.
Examples
>>> from ..polyclasses import DMP, DMF
>>> from ..domains import ZZ
>>> from ...abc import x
>>> f = DMF(([ZZ(1), ZZ(1)], [ZZ(1)]), ZZ)
>>> K = ZZ.old_frac_field(x)
>>> F = ZZ.old_poly_ring(x).from_FractionField(f, K)
>>> F == DMP([ZZ(1), ZZ(1)], ZZ)
True
>>> type(F)
<class 'sympy.polys.polyclasses.DMP'>
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype.
-
is_Poly = True
-
is_PolynomialRing = True
-
is_negative(a)[source]
Returns True if LC(a) is negative.
-
is_nonnegative(a)[source]
Returns True if LC(a) is non-negative.
-
is_nonpositive(a)[source]
Returns True if LC(a) is non-positive.
-
is_positive(a)[source]
Returns True if LC(a) is positive.
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
modelparameters.sympy.polys.domains.old_polynomialring.PolynomialRing(dom, *gens, **opts)[source]
Create a generalized multivariate polynomial ring.
A generalized polynomial ring is defined by a ground field K, a set
of generators (typically x_1, ldots, x_n) and a monomial order <.
The monomial order can be global, local or mixed. In any case it induces
a total ordering on the monomials, and there exists for every (non-zero)
polynomial f in K[x_1, ldots, x_n] a well-defined “leading monomial”
LM(f) = LM(f, >). One can then define a multiplicative subset
S = S_> = {f in K[x_1, ldots, x_n] | LM(f) = 1}. The generalized
polynomial ring corresponding to the monomial order is
R = S^{-1}K[x_1, ldots, x_n].
If > is a so-called global order, that is 1 is the smallest monomial,
then we just have S = K and R = K[x_1, ldots, x_n].
Examples
A few examples may make this clearer.
>>> from ...abc import x, y
>>> from ... import QQ
Our first ring uses global lexicographic order.
>>> R1 = QQ.old_poly_ring(x, y, order=(("lex", x, y),))
The second ring uses local lexicographic order. Note that when using a
single (non-product) order, you can just specify the name and omit the
variables:
>>> R2 = QQ.old_poly_ring(x, y, order="ilex")
The third and fourth rings use a mixed orders:
>>> o1 = (("ilex", x), ("lex", y))
>>> o2 = (("lex", x), ("ilex", y))
>>> R3 = QQ.old_poly_ring(x, y, order=o1)
>>> R4 = QQ.old_poly_ring(x, y, order=o2)
We will investigate what elements of K(x, y) are contained in the various
rings.
>>> L = [x, 1/x, y/(1 + x), 1/(1 + y), 1/(1 + x*y)]
>>> test = lambda R: [f in R for f in L]
The first ring is just K[x, y]:
>>> test(R1)
[True, False, False, False, False]
The second ring is R1 localised at the maximal ideal (x, y):
>>> test(R2)
[True, False, True, True, True]
The third ring is R1 localised at the prime ideal (x):
>>> test(R3)
[True, False, True, False, True]
Finally the fourth ring is R1 localised at S = K[x, y] setminus yK[y]:
>>> test(R4)
[True, False, False, True, False]
-
class modelparameters.sympy.polys.domains.old_polynomialring.PolynomialRingBase(dom, *gens, **opts)[source]
Bases: Ring
, CharacteristicZero
, CompositeDomain
Base class for generalized polynomial rings.
This base class should be used for uniform access to generalized polynomial
rings. Subclasses only supply information about the element storage etc.
Do not instantiate.
-
default_order = 'grevlex'
-
factorial(a)[source]
Returns factorial of a.
-
frac_field(*gens)[source]
Returns a fraction field, i.e. K(X).
-
free_module(rank)[source]
Generate a free module of rank rank
over self
.
>>> from ...abc import x
>>> from ... import QQ
>>> QQ.old_poly_ring(x).free_module(2)
QQ[x]**2
-
from_AlgebraicField(a, K0)[source]
Convert a ANP object to dtype.
-
from_GlobalPolynomialRing(a, K0)[source]
Convert a DMP object to dtype.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
gcd(a, b)[source]
Returns GCD of a and b.
-
gcdex(a, b)[source]
Extended GCD of a and b.
-
get_field()[source]
Returns a field associated with self.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
lcm(a, b)[source]
Returns LCM of a and b.
-
new(element)[source]
-
poly_ring(*gens)[source]
Returns a polynomial ring, i.e. K[X].
-
revert(a)[source]
Returns a**(-1)
if possible.
modelparameters.sympy.polys.domains.polynomialring module
Implementation of PolynomialRing
class.
-
class modelparameters.sympy.polys.domains.polynomialring.PolynomialRing(domain_or_ring, symbols=None, order=None)[source]
Bases: Ring
, CompositeDomain
A class for representing multivariate polynomial rings.
-
factorial(a)[source]
Returns factorial of a.
-
from_AlgebraicField(a, K0)[source]
Convert an algebraic number to dtype
.
-
from_FractionField(a, K0)[source]
Convert a rational function to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype.
-
gcd(a, b)[source]
Returns GCD of a and b.
-
gcdex(a, b)[source]
Extended GCD of a and b.
-
get_field()[source]
Returns a field associated with self.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Poly = True
-
is_PolynomialRing = True
-
is_negative(a)[source]
Returns True if LC(a) is negative.
-
is_nonnegative(a)[source]
Returns True if LC(a) is non-negative.
-
is_nonpositive(a)[source]
Returns True if LC(a) is non-positive.
-
is_positive(a)[source]
Returns True if LC(a) is positive.
-
lcm(a, b)[source]
Returns LCM of a and b.
-
new(element)[source]
-
property one
-
property order
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
property zero
modelparameters.sympy.polys.domains.pythonfinitefield module
Implementation of PythonFiniteField
class.
-
class modelparameters.sympy.polys.domains.pythonfinitefield.PythonFiniteField(mod, symmetric=True)[source]
Bases: FiniteField
Finite field based on Python’s integers.
-
alias = 'FF_python'
modelparameters.sympy.polys.domains.pythonintegerring module
Implementaton of PythonIntegerRing
class.
-
class modelparameters.sympy.polys.domains.pythonintegerring.PythonIntegerRing[source]
Bases: IntegerRing
Integer ring based on Python’s int
type.
-
alias = 'ZZ_python'
-
dtype
alias of int
-
factorial(a)[source]
Compute factorial of a
.
-
from_FF_gmpy(a, K0)[source]
Convert ModularInteger(mpz)
to Python’s int
.
-
from_FF_python(a, K0)[source]
Convert ModularInteger(int)
to Python’s int
.
-
from_QQ_gmpy(a, K0)[source]
Convert GMPY’s mpq
to Python’s int
.
-
from_QQ_python(a, K0)[source]
Convert Python’s Fraction
to Python’s int
.
-
from_RealField(a, K0)[source]
Convert mpmath’s mpf
to Python’s int
.
-
from_ZZ_gmpy(a, K0)[source]
Convert GMPY’s mpz
to Python’s int
.
-
from_ZZ_python(a, K0)[source]
Convert Python’s int
to Python’s int
.
-
from_sympy(a)[source]
Convert SymPy’s Integer to dtype
.
-
gcd(a, b)[source]
Compute GCD of a
and b
.
-
gcdex(a, b)[source]
Compute extended GCD of a
and b
.
-
lcm(a, b)[source]
Compute LCM of a
and b
.
-
one = 1
-
sqrt(a)[source]
Compute square root of a
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
zero = 0
modelparameters.sympy.polys.domains.pythonrational module
Rational number type based on Python integers.
-
class modelparameters.sympy.polys.domains.pythonrational.PythonRational(p, q=1, _gcd=True)[source]
Bases: DefaultPrinting
, PicklableWithSlots
, DomainElement
Rational number type based on Python integers.
This was supposed to be needed for compatibility with older Python
versions which don’t support Fraction. However, Fraction is very
slow so we don’t use it anyway.
Examples
>>> from ..domains import PythonRational
>>> PythonRational(1)
1
>>> PythonRational(2, 3)
2/3
>>> PythonRational(14, 10)
7/5
-
property denom
-
property denominator
-
classmethod new(p, q)[source]
-
property numer
-
property numerator
-
p
-
parent()[source]
-
q
modelparameters.sympy.polys.domains.pythonrationalfield module
Implementation of PythonRationalField
class.
-
class modelparameters.sympy.polys.domains.pythonrationalfield.PythonRationalField[source]
Bases: RationalField
Rational field based on Python rational number type.
-
alias = 'QQ_python'
-
denom(a)[source]
Returns denominator of a.
-
dtype
alias of PythonRational
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s Rational to dtype.
-
get_ring()[source]
Returns ring associated with self
.
-
numer(a)[source]
Returns numerator of a.
-
one = 1
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
zero = 0
modelparameters.sympy.polys.domains.quotientring module
Implementation of QuotientRing
class.
-
class modelparameters.sympy.polys.domains.quotientring.QuotientRingElement(ring, data)[source]
Bases: object
Class representing elements of (commutative) quotient rings.
Attributes:
modelparameters.sympy.polys.domains.rationalfield module
Implementation of RationalField
class.
-
class modelparameters.sympy.polys.domains.rationalfield.RationalField[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
General class for rational fields.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. mathbb{Q}(alpha, ldots).
-
from_AlgebraicField(a, K0)[source]
Convert a ANP
object to dtype
.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Numerical = True
-
is_QQ = True
-
is_RationalField = True
-
rep = 'QQ'
modelparameters.sympy.polys.domains.realfield module
Implementation of RealField
class.
-
class modelparameters.sympy.polys.domains.realfield.RealField(prec=53, dps=None, tol=None)[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
Real numbers up to the given precision.
-
almosteq(a, b, tolerance=None)[source]
Check if a
and b
are almost equal.
-
property dps
-
from_ComplexField(element, base)[source]
Convert a complex element to dtype
.
-
from_QQ_gmpy(element, base)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(element, base)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(element, base)[source]
Convert a real element object to dtype
.
-
from_ZZ_gmpy(element, base)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(element, base)[source]
Convert a Python int
object to dtype
.
-
from_sympy(expr)[source]
Convert SymPy’s number to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
-
get_exact()[source]
Returns an exact domain associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
property has_default_precision
-
is_Exact = False
-
is_Numerical = True
-
is_PID = False
-
is_RR = True
-
is_RealField = True
-
lcm(a, b)[source]
Returns LCM of a
and b
.
-
property precision
-
rep = 'RR'
-
to_rational(element, limit=True)[source]
Convert a real number to rational number.
-
to_sympy(element)[source]
Convert element
to SymPy number.
-
property tolerance
modelparameters.sympy.polys.domains.ring module
Implementation of Ring
class.
-
class modelparameters.sympy.polys.domains.ring.Ring[source]
Bases: Domain
Represents a ring domain.
-
denom(a)[source]
Returns denominator of a.
-
div(a, b)[source]
Division of a
and b
, implies __divmod__
.
-
exquo(a, b)[source]
Exact quotient of a
and b
, implies __floordiv__
.
-
free_module(rank)[source]
Generate a free module of rank rank
over self.
>>> from ...abc import x
>>> from ... import QQ
>>> QQ.old_poly_ring(x).free_module(2)
QQ[x]**2
-
get_ring()[source]
Returns a ring associated with self
.
-
ideal(*gens)[source]
Generate an ideal of self
.
>>> from ...abc import x
>>> from ... import QQ
>>> QQ.old_poly_ring(x).ideal(x**2)
<x**2>
-
invert(a, b)[source]
Returns inversion of a mod b
.
-
is_Ring = True
-
is_unit(a)[source]
-
numer(a)[source]
Returns numerator of a
.
-
quo(a, b)[source]
Quotient of a
and b
, implies __floordiv__
.
-
quotient_ring(e)[source]
Form a quotient ring of self
.
Here e
can be an ideal or an iterable.
>>> from ...abc import x
>>> from ... import QQ
>>> QQ.old_poly_ring(x).quotient_ring(QQ.old_poly_ring(x).ideal(x**2))
QQ[x]/<x**2>
>>> QQ.old_poly_ring(x).quotient_ring([x**2])
QQ[x]/<x**2>
The division operator has been overloaded for this:
>>> QQ.old_poly_ring(x)/[x**2]
QQ[x]/<x**2>
-
rem(a, b)[source]
Remainder of a
and b
, implies __mod__
.
-
revert(a)[source]
Returns a**(-1)
if possible.
modelparameters.sympy.polys.domains.simpledomain module
Implementation of SimpleDomain
class.
-
class modelparameters.sympy.polys.domains.simpledomain.SimpleDomain[source]
Bases: Domain
Base class for simple domains, e.g. ZZ, QQ.
-
inject(*gens)[source]
Inject generators into this domain.
-
is_Simple = True
Module contents
Implementation of mathematical domains.
-
class modelparameters.sympy.polys.domains.AlgebraicField(dom, *ext)[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
A class for representing algebraic number fields.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. mathbb{Q}(alpha, ldots).
-
denom(a)[source]
Returns denominator of a
.
-
dtype
alias of ANP
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf
object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
is_Algebraic = True
-
is_AlgebraicField = True
-
is_Numerical = True
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_positive(a)[source]
Returns True if a
is positive.
-
new(element)[source]
-
numer(a)[source]
Returns numerator of a
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
class modelparameters.sympy.polys.domains.ComplexField(prec=53, dps=None, tol=None)[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
Complex numbers up to the given precision.
-
almosteq(a, b, tolerance=None)[source]
Check if a
and b
are almost equal.
-
property dps
-
from_ComplexField(element, base)[source]
Convert a complex element to dtype
.
-
from_QQ_gmpy(element, base)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(element, base)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(element, base)[source]
Convert a real element object to dtype
.
-
from_ZZ_gmpy(element, base)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(element, base)[source]
Convert a Python int
object to dtype
.
-
from_sympy(expr)[source]
Convert SymPy’s number to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
-
get_exact()[source]
Returns an exact domain associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
property has_default_precision
-
is_CC = True
-
is_ComplexField = True
-
is_Exact = False
-
is_Numerical = True
-
lcm(a, b)[source]
Returns LCM of a
and b
.
-
property precision
-
rep = 'CC'
-
to_sympy(element)[source]
Convert element
to SymPy number.
-
property tolerance
-
class modelparameters.sympy.polys.domains.Domain[source]
Bases: object
Represents an abstract domain.
-
abs(a)[source]
Absolute value of a
, implies __abs__
.
-
add(a, b)[source]
Sum of a
and b
, implies __add__
.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. K(alpha, ldots).
-
alias = None
-
almosteq(a, b, tolerance=None)[source]
Check if a
and b
are almost equal.
-
characteristic()[source]
Return the characteristic of this domain.
-
cofactors(a, b)[source]
Returns GCD and cofactors of a
and b
.
-
convert(element, base=None)[source]
Convert element
to self.dtype
.
-
convert_from(element, base)[source]
Convert element
to self.dtype
given the base domain.
-
denom(a)[source]
Returns denominator of a
.
-
div(a, b)[source]
Division of a
and b
, implies something.
-
dtype = None
-
evalf(a, prec=None, **options)[source]
Returns numerical approximation of a
.
-
exquo(a, b)[source]
Exact quotient of a
and b
, implies something.
-
frac_field(*symbols, **kwargs)[source]
Returns a fraction field, i.e. K(X).
-
from_AlgebraicField(a, K0)[source]
Convert an algebraic number to dtype
.
-
from_ComplexField(a, K0)[source]
Convert a complex element to dtype
.
-
from_ExpressionDomain(a, K0)[source]
Convert a EX
object to dtype
.
-
from_FF_gmpy(a, K0)[source]
Convert ModularInteger(mpz)
to dtype
.
-
from_FF_python(a, K0)[source]
Convert ModularInteger(int)
to dtype
.
-
from_FractionField(a, K0)[source]
Convert a rational function to dtype
.
-
from_GeneralizedPolynomialRing(a, K0)[source]
-
from_GlobalPolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a real element object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert a SymPy object to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
-
gcdex(a, b)[source]
Extended GCD of a
and b
.
-
get_exact()[source]
Returns an exact domain associated with self
.
-
get_field()[source]
Returns a field associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
half_gcdex(a, b)[source]
Half extended GCD of a
and b
.
-
has_CharacteristicZero = False
-
property has_Field
-
property has_Ring
-
has_assoc_Field = False
-
has_assoc_Ring = False
-
imag(a)[source]
-
inject(*symbols)[source]
Inject generators into this domain.
-
invert(a, b)[source]
Returns inversion of a mod b
, implies something.
-
is_Algebraic = False
-
is_AlgebraicField = False
-
is_CC = False
-
is_ComplexField = False
-
is_Composite = False
-
is_EX = False
-
is_Exact = True
-
is_FF = False
-
is_Field = False
-
is_FiniteField = False
-
is_Frac = False
-
is_FractionField = False
-
is_IntegerRing = False
-
is_Numerical = False
-
is_PID = False
-
is_Poly = False
-
is_PolynomialRing = False
-
is_QQ = False
-
is_RR = False
-
is_RationalField = False
-
is_RealField = False
-
is_Ring = False
-
is_Simple = False
-
is_SymbolicDomain = False
-
is_ZZ = False
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_one(a)[source]
Returns True if a
is one.
-
is_positive(a)[source]
Returns True if a
is positive.
-
is_zero(a)[source]
Returns True if a
is zero.
-
lcm(a, b)[source]
Returns LCM of a
and b
.
-
log(a, b)[source]
Returns b-base logarithm of a
.
-
map(seq)[source]
Rersively apply self
to all elements of seq
.
-
mul(a, b)[source]
Product of a
and b
, implies __mul__
.
-
n(a, prec=None, **options)
Returns numerical approximation of a
.
-
neg(a)[source]
Returns a
negated, implies __neg__
.
-
new(*args)[source]
-
normal(*args)[source]
-
numer(a)[source]
Returns numerator of a
.
-
of_type(element)[source]
Check if a
is of type dtype
.
-
old_frac_field(*symbols, **kwargs)[source]
Returns a fraction field, i.e. K(X).
-
old_poly_ring(*symbols, **kwargs)[source]
Returns a polynomial ring, i.e. K[X].
-
one = None
-
poly_ring(*symbols, **kwargs)[source]
Returns a polynomial ring, i.e. K[X].
-
pos(a)[source]
Returns a
positive, implies __pos__
.
-
pow(a, b)[source]
Raise a
to power b
, implies __pow__
.
-
quo(a, b)[source]
Quotient of a
and b
, implies something.
-
real(a)[source]
-
rem(a, b)[source]
Remainder of a
and b
, implies __mod__
.
-
rep = None
-
revert(a)[source]
Returns a**(-1)
if possible.
-
sqrt(a)[source]
Returns square root of a
.
-
sub(a, b)[source]
Difference of a
and b
, implies __sub__
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
property tp
-
unify(K1, symbols=None)[source]
Construct a minimal domain that contains elements of K0
and K1
.
Known domains (from smallest to largest):
GF(p)
ZZ
QQ
RR(prec, tol)
CC(prec, tol)
ALG(a, b, c)
K[x, y, z]
K(x, y, z)
EX
-
unify_with_symbols(K1, symbols)[source]
-
zero = None
-
class modelparameters.sympy.polys.domains.ExpressionDomain[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
A class for arbitrary expressions.
-
class Expression(ex)[source]
Bases: PicklableWithSlots
An arbitrary expression.
-
as_expr()[source]
-
denom()[source]
-
ex
-
gcd(g)[source]
-
lcm(g)[source]
-
numer()[source]
-
simplify(ex)[source]
-
denom(a)[source]
Returns denominator of a
.
-
dtype
alias of Expression
-
from_ExpressionDomain(a, K0)[source]
Convert a EX
object to dtype
.
-
from_FractionField(a, K0)[source]
Convert a DMF
object to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a DMP
object to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf
object to dtype
.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(a, K0)[source]
Convert a Python int
object to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
This definition of GCD over fields allows to clear denominators
in primitive().
>>> from ..domains import QQ
>>> from ... import S, gcd, primitive
>>> from ...abc import x
>>> QQ.gcd(QQ(2, 3), QQ(4, 9))
2/9
>>> gcd(S(2)/3, S(4)/9)
2/9
>>> primitive(2*x/3 + S(4)/9)
(2/9, 3*x + 2)
-
get_field()[source]
Returns a field associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
is_EX = True
-
is_SymbolicDomain = True
-
is_negative(a)[source]
Returns True if a
is negative.
-
is_nonnegative(a)[source]
Returns True if a
is non-negative.
-
is_nonpositive(a)[source]
Returns True if a
is non-positive.
-
is_positive(a)[source]
Returns True if a
is positive.
-
lcm(a, b)[source]
Returns LCM of a
and b
.
>>> from ..domains import QQ
>>> from ... import S, lcm
>>> QQ.lcm(QQ(2, 3), QQ(4, 9))
4/3
>>> lcm(S(2)/3, S(4)/9)
4/3
-
numer(a)[source]
Returns numerator of a
.
-
one = EX(1)
-
rep = 'EX'
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
zero = EX(0)
-
modelparameters.sympy.polys.domains.FF
alias of PythonFiniteField
-
modelparameters.sympy.polys.domains.FF_gmpy
alias of GMPYFiniteField
-
modelparameters.sympy.polys.domains.FF_python
alias of PythonFiniteField
-
class modelparameters.sympy.polys.domains.FiniteField(mod, dom=None, symmetric=True)[source]
Bases: Field
, SimpleDomain
General class for finite fields.
-
characteristic()[source]
Return the characteristic of this domain.
-
dom = None
-
from_FF_gmpy(a, K0=None)[source]
Convert ModularInteger(mpz)
to dtype
.
-
from_FF_python(a, K0=None)[source]
Convert ModularInteger(int)
to dtype
.
-
from_QQ_gmpy(a, K0=None)[source]
Convert GMPY’s mpq
to dtype
.
-
from_QQ_python(a, K0=None)[source]
Convert Python’s Fraction
to dtype
.
-
from_RealField(a, K0)[source]
Convert mpmath’s mpf
to dtype
.
-
from_ZZ_gmpy(a, K0=None)[source]
Convert GMPY’s mpz
to dtype
.
-
from_ZZ_python(a, K0=None)[source]
Convert Python’s int
to dtype
.
-
from_sympy(a)[source]
Convert SymPy’s Integer to SymPy’s Integer
.
-
get_field()[source]
Returns a field associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
is_FF = True
-
is_FiniteField = True
-
is_Numerical = True
-
mod = None
-
rep = 'FF'
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
class modelparameters.sympy.polys.domains.FractionField(domain_or_field, symbols=None, order=None)[source]
Bases: Field
, CompositeDomain
A class for representing multivariate rational function fields.
-
denom(a)[source]
Returns denominator of a
.
-
factorial(a)[source]
Returns factorial of a.
-
from_AlgebraicField(a, K0)[source]
Convert an algebraic number to dtype
.
-
from_FractionField(a, K0)[source]
Convert a rational function to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype.
-
get_ring()[source]
Returns a field associated with self.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Frac = True
-
is_FractionField = True
-
is_negative(a)[source]
Returns True if LC(a) is negative.
-
is_nonnegative(a)[source]
Returns True if LC(a) is non-negative.
-
is_nonpositive(a)[source]
Returns True if LC(a) is non-positive.
-
is_positive(a)[source]
Returns True if LC(a) is positive.
-
new(element)[source]
-
numer(a)[source]
Returns numerator of a
.
-
property one
-
property order
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
property zero
-
modelparameters.sympy.polys.domains.GF
alias of PythonFiniteField
-
class modelparameters.sympy.polys.domains.GMPYFiniteField(mod, symmetric=True)[source]
Bases: FiniteField
Finite field based on GMPY integers.
-
alias = 'FF_gmpy'
-
class modelparameters.sympy.polys.domains.GMPYIntegerRing[source]
Bases: IntegerRing
Integer ring based on GMPY’s mpz
type.
-
alias = 'ZZ_gmpy'
-
dtype
alias of GMPYInteger
-
factorial(a)[source]
Compute factorial of a
.
-
from_FF_gmpy(a, K0)[source]
Convert ModularInteger(mpz)
to GMPY’s mpz
.
-
from_FF_python(a, K0)[source]
Convert ModularInteger(int)
to GMPY’s mpz
.
-
from_QQ_gmpy(a, K0)[source]
Convert GMPY mpq
to GMPY’s mpz
.
-
from_QQ_python(a, K0)[source]
Convert Python’s Fraction
to GMPY’s mpz
.
-
from_RealField(a, K0)[source]
Convert mpmath’s mpf
to GMPY’s mpz
.
-
from_ZZ_gmpy(a, K0)[source]
Convert GMPY’s mpz
to GMPY’s mpz
.
-
from_ZZ_python(a, K0)[source]
Convert Python’s int
to GMPY’s mpz
.
-
from_sympy(a)[source]
Convert SymPy’s Integer to dtype
.
-
gcd(a, b)[source]
Compute GCD of a
and b
.
-
gcdex(a, b)[source]
Compute extended GCD of a
and b
.
-
lcm(a, b)[source]
Compute LCM of a
and b
.
-
one = <modelparameters.sympy.polys.domains.groundtypes.GMPYInteger object>
-
sqrt(a)[source]
Compute square root of a
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
tp
alias of GMPYInteger
-
zero = <modelparameters.sympy.polys.domains.groundtypes.GMPYInteger object>
-
class modelparameters.sympy.polys.domains.GMPYRationalField[source]
Bases: RationalField
Rational field based on GMPY mpq class.
-
alias = 'QQ_gmpy'
-
denom(a)[source]
Returns denominator of a.
-
div(a, b)[source]
Division of a and b, implies __div__.
-
dtype
alias of GMPYRational
-
exquo(a, b)[source]
Exact quotient of a and b, implies __div__.
-
factorial(a)[source]
Returns factorial of a.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s Integer to dtype.
-
get_ring()[source]
Returns ring associated with self
.
-
numer(a)[source]
Returns numerator of a.
-
one = <modelparameters.sympy.polys.domains.groundtypes.GMPYRational object>
-
quo(a, b)[source]
Quotient of a and b, implies __div__.
-
rem(a, b)[source]
Remainder of a and b, implies nothing.
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
tp
alias of GMPYRational
-
zero = <modelparameters.sympy.polys.domains.groundtypes.GMPYRational object>
-
class modelparameters.sympy.polys.domains.IntegerRing[source]
Bases: Ring
, CharacteristicZero
, SimpleDomain
General class for integer rings.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. mathbb{Q}(alpha, ldots).
-
from_AlgebraicField(a, K0)[source]
Convert a ANP
object to dtype
.
-
get_field()[source]
Returns a field associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_IntegerRing = True
-
is_Numerical = True
-
is_PID = True
-
is_ZZ = True
-
log(a, b)[source]
Returns b-base logarithm of a
.
-
rep = 'ZZ'
-
class modelparameters.sympy.polys.domains.PolynomialRing(domain_or_ring, symbols=None, order=None)[source]
Bases: Ring
, CompositeDomain
A class for representing multivariate polynomial rings.
-
factorial(a)[source]
Returns factorial of a.
-
from_AlgebraicField(a, K0)[source]
Convert an algebraic number to dtype
.
-
from_FractionField(a, K0)[source]
Convert a rational function to dtype
.
-
from_PolynomialRing(a, K0)[source]
Convert a polynomial to dtype
.
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s expression to dtype.
-
gcd(a, b)[source]
Returns GCD of a and b.
-
gcdex(a, b)[source]
Extended GCD of a and b.
-
get_field()[source]
Returns a field associated with self.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Poly = True
-
is_PolynomialRing = True
-
is_negative(a)[source]
Returns True if LC(a) is negative.
-
is_nonnegative(a)[source]
Returns True if LC(a) is non-negative.
-
is_nonpositive(a)[source]
Returns True if LC(a) is non-positive.
-
is_positive(a)[source]
Returns True if LC(a) is positive.
-
lcm(a, b)[source]
Returns LCM of a and b.
-
new(element)[source]
-
property one
-
property order
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
property zero
-
class modelparameters.sympy.polys.domains.PythonFiniteField(mod, symmetric=True)[source]
Bases: FiniteField
Finite field based on Python’s integers.
-
alias = 'FF_python'
-
class modelparameters.sympy.polys.domains.PythonIntegerRing[source]
Bases: IntegerRing
Integer ring based on Python’s int
type.
-
alias = 'ZZ_python'
-
dtype
alias of int
-
factorial(a)[source]
Compute factorial of a
.
-
from_FF_gmpy(a, K0)[source]
Convert ModularInteger(mpz)
to Python’s int
.
-
from_FF_python(a, K0)[source]
Convert ModularInteger(int)
to Python’s int
.
-
from_QQ_gmpy(a, K0)[source]
Convert GMPY’s mpq
to Python’s int
.
-
from_QQ_python(a, K0)[source]
Convert Python’s Fraction
to Python’s int
.
-
from_RealField(a, K0)[source]
Convert mpmath’s mpf
to Python’s int
.
-
from_ZZ_gmpy(a, K0)[source]
Convert GMPY’s mpz
to Python’s int
.
-
from_ZZ_python(a, K0)[source]
Convert Python’s int
to Python’s int
.
-
from_sympy(a)[source]
Convert SymPy’s Integer to dtype
.
-
gcd(a, b)[source]
Compute GCD of a
and b
.
-
gcdex(a, b)[source]
Compute extended GCD of a
and b
.
-
lcm(a, b)[source]
Compute LCM of a
and b
.
-
one = 1
-
sqrt(a)[source]
Compute square root of a
.
-
to_sympy(a)[source]
Convert a
to a SymPy object.
-
zero = 0
-
class modelparameters.sympy.polys.domains.PythonRationalField[source]
Bases: RationalField
Rational field based on Python rational number type.
-
alias = 'QQ_python'
-
denom(a)[source]
Returns denominator of a.
-
dtype
alias of PythonRational
-
from_QQ_gmpy(a, K0)[source]
Convert a GMPY mpq object to dtype.
-
from_QQ_python(a, K0)[source]
Convert a Python Fraction object to dtype.
-
from_RealField(a, K0)[source]
Convert a mpmath mpf object to dtype.
-
from_ZZ_gmpy(a, K0)[source]
Convert a GMPY mpz object to dtype.
-
from_ZZ_python(a, K0)[source]
Convert a Python int object to dtype.
-
from_sympy(a)[source]
Convert SymPy’s Rational to dtype.
-
get_ring()[source]
Returns ring associated with self
.
-
numer(a)[source]
Returns numerator of a.
-
one = 1
-
to_sympy(a)[source]
Convert a to a SymPy object.
-
zero = 0
-
modelparameters.sympy.polys.domains.QQ_gmpy
alias of GMPYRationalField
-
modelparameters.sympy.polys.domains.QQ_python
alias of PythonRationalField
-
class modelparameters.sympy.polys.domains.RationalField[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
General class for rational fields.
-
algebraic_field(*extension)[source]
Returns an algebraic field, i.e. mathbb{Q}(alpha, ldots).
-
from_AlgebraicField(a, K0)[source]
Convert a ANP
object to dtype
.
-
has_assoc_Field = True
-
has_assoc_Ring = True
-
is_Numerical = True
-
is_QQ = True
-
is_RationalField = True
-
rep = 'QQ'
-
class modelparameters.sympy.polys.domains.RealField(prec=53, dps=None, tol=None)[source]
Bases: Field
, CharacteristicZero
, SimpleDomain
Real numbers up to the given precision.
-
almosteq(a, b, tolerance=None)[source]
Check if a
and b
are almost equal.
-
property dps
-
from_ComplexField(element, base)[source]
Convert a complex element to dtype
.
-
from_QQ_gmpy(element, base)[source]
Convert a GMPY mpq
object to dtype
.
-
from_QQ_python(element, base)[source]
Convert a Python Fraction
object to dtype
.
-
from_RealField(element, base)[source]
Convert a real element object to dtype
.
-
from_ZZ_gmpy(element, base)[source]
Convert a GMPY mpz
object to dtype
.
-
from_ZZ_python(element, base)[source]
Convert a Python int
object to dtype
.
-
from_sympy(expr)[source]
Convert SymPy’s number to dtype
.
-
gcd(a, b)[source]
Returns GCD of a
and b
.
-
get_exact()[source]
Returns an exact domain associated with self
.
-
get_ring()[source]
Returns a ring associated with self
.
-
has_assoc_Field = True
-
has_assoc_Ring = False
-
property has_default_precision
-
is_Exact = False
-
is_Numerical = True
-
is_PID = False
-
is_RR = True
-
is_RealField = True
-
lcm(a, b)[source]
Returns LCM of a
and b
.
-
property precision
-
rep = 'RR'
-
to_rational(element, limit=True)[source]
Convert a real number to rational number.
-
to_sympy(element)[source]
Convert element
to SymPy number.
-
property tolerance
-
modelparameters.sympy.polys.domains.ZZ_gmpy
alias of GMPYIntegerRing
-
modelparameters.sympy.polys.domains.ZZ_python
alias of PythonIntegerRing