本文整理汇总了Python中sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing.one方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.one方法的具体用法?Python PolynomialRing.one怎么用?Python PolynomialRing.one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing.one方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestGradedModule
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
class TestGradedModule(unittest.TestCase):
def setUp(self):
self.poly_ring = PolynomialRing(QQ,"x",3);
self.x = self.poly_ring.gens()[0];
self.y = self.poly_ring.gens()[1];
self.z = self.poly_ring.gens()[2];
def test_monomial_basis_zero(self):
one = self.poly_ring.one()
zero = self.poly_ring.zero()
gm = GradedModule([[one,one,one,one]],[0,1,2,3],[1,2,3])
self.assertEqual(gm.monomial_basis(0),[(one,zero,zero,zero)])
def test_monomial_basis(self):
x = self.x
y = self.y
one = self.poly_ring.one()
zero = self.poly_ring.zero()
gm = GradedModule([[one,one]],[0,1],[1,2,3])
true_basis = [(x**2,zero),(y,zero),(zero,x)]
self.assertEqual(Set(gm.monomial_basis(2)),Set(true_basis))
def test_homogeneous_parts_A(self):
one = self.poly_ring.one()
zero = self.poly_ring.zero()
gm = GradedModule([[one,one]],[0,1],[1,2,3])
parts = gm.get_homogeneous_parts([one,one])
parts_true = { 0:[one,zero] , 1:[zero,one] }
self.assertEqual(parts,parts_true)
def test_homogeneous_parts_B(self):
x = self.x
y = self.y
z = self.z
one = self.poly_ring.one()
zero = self.poly_ring.zero()
gm = GradedModule([[one,one]],[0,1],[1,2,3])
parts = gm.get_homogeneous_parts([x*y,x**3+z*y])
self.assertEqual(parts,{3:[x*y,zero],4:[zero,x**3],6:[zero,z*y]})
def test_homogeneous_part_basisA(self):
x = self.x
y = self.y
z = self.z
one = self.poly_ring.one()
gm = GradedModule([[z,one,x**2 + y]],[0,1,2],[1,2,3])
basis = gm.homogeneous_part_basis(6);
self.assertEqual(len(basis),10)
def test_homogeneous_part_basisB(self):
#From bug found with ncd
x = self.x
y = self.y
z = self.z
zero = self.poly_ring.zero()
gm = GradedModule([[zero, x*z, x*y], [zero, -x*z, zero], [y*z, zero, zero]],[1, 1, 1],[1, 1, 1])
basis = gm.homogeneous_part_basis(3);
self.assertEqual(len(basis),3)
示例2: rand_w_hom_divisor
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def rand_w_hom_divisor(n,degs=None,mon_num=None,var="z"):
if degs==None:
degs = [randrange(2,6) for _ in range(n)]
deg = sum(degs)
if mon_num==None:
mon_num = randrange(2,8)
poly_ring = PolynomialRing(QQ,n,var)
div = poly_ring.zero()
min_w = min(degs)
for i in range(mon_num):
expo = [0]*n
cur_deg = 0
while cur_deg!=deg:
if cur_deg>deg:
expo = [0]*n
cur_deg = 0
if deg-cur_deg<min_w:
expo = [0]*n
cur_deg = 0
next_g = randrange(0,n)
expo[next_g] += 1
cur_deg += degs[next_g]
coeff = randrange(-n,n)/n
mon = poly_ring.one()
for i,e in enumerate(expo):
mon *= poly_ring.gens()[i]**e
div += coeff*mon
return div
示例3: TestMonomialsOfOrder
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
class TestMonomialsOfOrder(unittest.TestCase):
def setUp(self):
self.poly_ring = PolynomialRing(QQ,"x",3);
self.x = self.poly_ring.gens()[0];
self.y = self.poly_ring.gens()[1];
self.z = self.poly_ring.gens()[2];
def test_zero(self):
mons = [mon for mon in monomials_of_order(0,self.poly_ring,[1,1,1])]
self.assertEqual(mons,[self.poly_ring.one()])
def test_homogeneous_3(self):
x = self.x;
y = self.y;
z = self.z;
true_mons = Set([x**3,y**3,z**3,x**2*y,x**2*z,y**2*x,y**2*z,z**2*x,z**2*y,x*y*z])
mons = [mon for mon in monomials_of_order(3,self.poly_ring,[1,1,1])]
self.assertEqual(true_mons,Set(mons))
def test_non_homogeneous_4(self):
x = self.x;
y = self.y;
z = self.z;
true_mons = Set([x**4,x**2*y,x*z,y**2])
mons = [mon for mon in monomials_of_order(4,self.poly_ring,[1,2,3])]
self.assertEqual(true_mons,Set(mons))
示例4: braid_divisor
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def braid_divisor(n,var="z"):
poly_ring = PolynomialRing(QQ,n,var)
div = poly_ring.one()
gens = poly_ring.gens()
for i in range(n):
for j in range(i+1,n):
div *= (gens[i]-gens[j])
return div
示例5: test_p_module_n_crossing
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def test_p_module_n_crossing(self):
#Make sure this doesnt throw an error - fix bug
for i in range(4,5):
p_ring = PolynomialRing(QQ,i,"z")
crossing = p_ring.one()
for g in p_ring.gens():
crossing *= g
logdf = LogarithmicDifferentialForms(crossing)
logdf.p_module(i-1)
示例6: demazure_character
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def demazure_character(self, weight, reduced_word = False):
r"""
Returns the Demazure character associated to the specified
weight in the ambient weight lattice.
INPUT:
- ``weight`` -- an element of the weight lattice
realization of the crystal, or a reduced word
- ``reduced_word`` -- a boolean (default: ``False``)
whether ``weight`` is given as a reduced word
This is currently only supported for crystals whose
underlying weight space is the ambient space.
EXAMPLES::
sage: T = CrystalOfTableaux(['A',2], shape = [2,1])
sage: e = T.weight_lattice_realization().basis()
sage: weight = e[0] + 2*e[2]
sage: weight.reduced_word()
[2, 1]
sage: T.demazure_character(weight)
x1^2*x2 + x1^2*x3 + x1*x2^2 + x1*x2*x3 + x1*x3^2
sage: T = CrystalOfTableaux(['A',3],shape=[2,1])
sage: T.demazure_character([1,2,3], reduced_word = True)
x1^2*x2 + x1^2*x3 + x1*x2^2 + x1*x2*x3 + x2^2*x3
sage: T = CrystalOfTableaux(['B',2], shape = [2])
sage: e = T.weight_lattice_realization().basis()
sage: weight = -2*e[1]
sage: T.demazure_character(weight)
x1^2 + x1*x2 + x2^2 + x1 + x2 + x1/x2 + 1/x2 + 1/x2^2 + 1
TODO: detect automatically if weight is a reduced word,
and remove the (untested!) ``reduced_word`` option.
REFERENCES::
.. [D1974] M. Demazure, Desingularisation des varietes de Schubert,
Ann. E. N. S., Vol. 6, (1974), p. 163-172
.. [M2009] Sarah Mason, An Explicit Construction of Type A Demazure Atoms,
Journal of Algebraic Combinatorics, Vol. 29, (2009), No. 3, p.295-313
(arXiv:0707.4267)
"""
from sage.misc.misc_c import prod
from sage.rings.rational_field import QQ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
if reduced_word:
word = weight
else:
word = weight.reduced_word()
n = self.weight_lattice_realization().n
u = list( self.module_generators )
for i in reversed(word):
u = u + sum((x.demazure_operator(i, truncated = True) for x in u), [])
x = ['x%s'%i for i in range(1,n+1)]
P = PolynomialRing(QQ, x)
u = [b.weight() for b in u]
return sum((prod((x[i]**(la[i]) for i in range(n)), P.one()) for la in u), P.zero())
示例7: demazure_character
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def demazure_character(self, w, f = None):
r"""
Returns the Demazure character associated to ``w``.
INPUT:
- ``w`` -- an element of the ambient weight lattice
realization of the crystal, or a reduced word, or an element
in the associated Weyl group
OPTIONAL:
- ``f`` -- a function from the crystal to a module
This is currently only supported for crystals whose underlying
weight space is the ambient space.
The Demazure character is obtained by applying the Demazure operator
`D_w` (see :meth:`sage.categories.regular_crystals.RegularCrystals.ParentMethods.demazure_operator`)
to the highest weight element of the classical crystal. The simple
Demazure operators `D_i` (see
:meth:`sage.categories.regular_crystals.RegularCrystals.ElementMethods.demazure_operator_simple`)
do not braid on the level of crystals, but on the level of characters they do.
That is why it makes sense to input ``w`` either as a weight, a reduced word,
or as an element of the underlying Weyl group.
EXAMPLES::
sage: T = crystals.Tableaux(['A',2], shape = [2,1])
sage: e = T.weight_lattice_realization().basis()
sage: weight = e[0] + 2*e[2]
sage: weight.reduced_word()
[2, 1]
sage: T.demazure_character(weight)
x1^2*x2 + x1*x2^2 + x1^2*x3 + x1*x2*x3 + x1*x3^2
sage: T = crystals.Tableaux(['A',3],shape=[2,1])
sage: T.demazure_character([1,2,3])
x1^2*x2 + x1*x2^2 + x1^2*x3 + x1*x2*x3 + x2^2*x3
sage: W = WeylGroup(['A',3])
sage: w = W.from_reduced_word([1,2,3])
sage: T.demazure_character(w)
x1^2*x2 + x1*x2^2 + x1^2*x3 + x1*x2*x3 + x2^2*x3
sage: T = crystals.Tableaux(['B',2], shape = [2])
sage: e = T.weight_lattice_realization().basis()
sage: weight = -2*e[1]
sage: T.demazure_character(weight)
x1^2 + x1*x2 + x2^2 + x1 + x2 + x1/x2 + 1/x2 + 1/x2^2 + 1
sage: T = crystals.Tableaux("B2",shape=[1/2,1/2])
sage: b2=WeylCharacterRing("B2",base_ring=QQ).ambient()
sage: T.demazure_character([1,2],f=lambda x:b2(x.weight()))
b2(-1/2,1/2) + b2(1/2,-1/2) + b2(1/2,1/2)
REFERENCES:
- [De1974]_
- [Ma2009]_
"""
from sage.misc.misc_c import prod
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
if hasattr(w, 'reduced_word'):
word = w.reduced_word()
else:
word = w
n = self.weight_lattice_realization().n
u = self.algebra(ZZ).sum_of_monomials(self.module_generators)
u = self.demazure_operator(u, word)
if f is None:
x = ['x%s'%i for i in range(1,n+1)]
P = PolynomialRing(ZZ, x)
# TODO: use P.linear_combination when PolynomialRing will be a ModulesWithBasis
return sum((coeff*prod((x[i]**(c.weight()[i]) for i in range(n)), P.one()) for c, coeff in u), P.zero())
else:
return sum((coeff*f(c)) for c, coeff in u)
示例8: crossing_divisor
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def crossing_divisor(n=3,var="z"):
poly_ring = PolynomialRing(QQ,n,var)
div = poly_ring.one()
for g in poly_ring.gens():
div *= g
return div
示例9: permanental_minor_polynomial
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def permanental_minor_polynomial(A, permanent_only=False, var='t', prec=None):
r"""
Return the polynomial of the sums of permanental minors of ``A``.
INPUT:
- `A` -- a matrix
- `permanent_only` -- if True, return only the permanent of `A`
- `var` -- name of the polynomial variable
- `prec` -- if prec is not None, truncate the polynomial at precision `prec`
The polynomial of the sums of permanental minors is
.. MATH::
\sum_{i=0}^{min(nrows, ncols)} p_i(A) x^i
where `p_i(A)` is the `i`-th permanental minor of `A` (that can also be
obtained through the method
:meth:`~sage.matrix.matrix2.Matrix.permanental_minor` via
``A.permanental_minor(i)``).
The algorithm implemented by that function has been developed by P. Butera
and M. Pernici, see [ButPer]. Its complexity is `O(2^n m^2 n)` where `m` and
`n` are the number of rows and columns of `A`. Moreover, if `A` is a banded
matrix with width `w`, that is `A_{ij}=0` for `|i - j| > w` and `w < n/2`,
then the complexity of the algorithm is `O(4^w (w+1) n^2)`.
INPUT:
- ``A`` -- matrix
- ``permanent_only`` -- optional boolean. If ``True``, only the permanent
is computed (might be faster).
- ``var`` -- a variable name
EXAMPLES::
sage: from sage.matrix.matrix_misc import permanental_minor_polynomial
sage: m = matrix([[1,1],[1,2]])
sage: permanental_minor_polynomial(m)
3*t^2 + 5*t + 1
sage: permanental_minor_polynomial(m, permanent_only=True)
3
sage: permanental_minor_polynomial(m, prec=2)
5*t + 1
::
sage: M = MatrixSpace(ZZ,4,4)
sage: A = M([1,0,1,0,1,0,1,0,1,0,10,10,1,0,1,1])
sage: permanental_minor_polynomial(A)
84*t^3 + 114*t^2 + 28*t + 1
sage: [A.permanental_minor(i) for i in range(5)]
[1, 28, 114, 84, 0]
An example over `\QQ`::
sage: M = MatrixSpace(QQ,2,2)
sage: A = M([1/5,2/7,3/2,4/5])
sage: permanental_minor_polynomial(A, True)
103/175
An example with polynomial coefficients::
sage: R.<a> = PolynomialRing(ZZ)
sage: A = MatrixSpace(R,2)([[a,1], [a,a+1]])
sage: permanental_minor_polynomial(A, True)
a^2 + 2*a
A usage of the ``var`` argument::
sage: m = matrix(ZZ,4,[0,1,2,3,1,2,3,0,2,3,0,1,3,0,1,2])
sage: permanental_minor_polynomial(m, var='x')
164*x^4 + 384*x^3 + 172*x^2 + 24*x + 1
ALGORITHM:
The permanent `perm(A)` of a `n \times n` matrix `A` is the coefficient
of the `x_1 x_2 \ldots x_n` monomial in
.. MATH::
\prod_{i=1}^n \left( \sum_{j=1}^n A_{ij} x_j \right)
Evaluating this product one can neglect `x_i^2`, that is `x_i`
can be considered to be nilpotent of order `2`.
To formalize this procedure, consider the algebra
`R = K[\eta_1, \eta_2, \ldots, \eta_n]` where the `\eta_i` are
commuting, nilpotent of order `2` (i.e. `\eta_i^2 = 0`).
Formally it is the quotient ring of the polynomial
ring in `\eta_1, \eta_2, \ldots, \eta_n` quotiented by the ideal
generated by the `\eta_i^2`.
#.........这里部分代码省略.........
示例10: QSystem
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
class QSystem(CombinatorialFreeModule):
r"""
A Q-system.
Let `\mathfrak{g}` be a tamely-laced symmetrizable Kac-Moody algebra
with index set `I` over a field `k`. Follow the presentation given
in [HKOTY1999]_, an unrestricted Q-system is a `k`-algebra in infinitely
many variables `Q^{(a)}_m`, where `a \in I` and `m \in \ZZ_{>0}`,
that satisifies the relations
.. MATH::
\left(Q^{(a)}_m\right)^2 = Q^{(a)}_{m+1} Q^{(a)}_{m-1} +
\prod_{b \sim a} \prod_{k=0}^{-C_{ab} - 1}
Q^{(b)}_{\left\lfloor \frac{m C_{ba} - k}{C_{ab}} \right\rfloor},
with `Q^{(a)}_0 := 1`. Q-systems can be considered as T-systems where
we forget the spectral parameter `u` and for `\mathfrak{g}` of finite
type, have a solution given by the characters of Kirillov-Reshetikhin
modules (again without the spectral parameter) for an affine Kac-Moody
algebra `\widehat{\mathfrak{g}}` with `\mathfrak{g}` as its classical
subalgebra. See [KNS2011]_ for more information.
Q-systems have a natural bases given by polynomials of the
fundamental representations `Q^{(a)}_1`, for `a \in I`. As such, we
consider the Q-system as generated by `\{ Q^{(a)}_1 \}_{a \in I}`.
There is also a level `\ell` restricted Q-system (with unit boundary
condition) given by setting `Q_{d_a \ell}^{(a)} = 1`, where `d_a`
are the entries of the symmetrizing matrix for the dual type of
`\mathfrak{g}`.
EXAMPLES:
We begin by constructing a Q-system and doing some basic computations
in type `A_4`::
sage: Q = QSystem(QQ, ['A', 4])
sage: Q.Q(3,1)
Q^(3)[1]
sage: Q.Q(1,2)
Q^(1)[1]^2 - Q^(2)[1]
sage: Q.Q(3,3)
-Q^(1)[1]*Q^(3)[1] + Q^(1)[1]*Q^(4)[1]^2 + Q^(2)[1]^2
- 2*Q^(2)[1]*Q^(3)[1]*Q^(4)[1] + Q^(3)[1]^3
sage: x = Q.Q(1,1) + Q.Q(2,1); x
Q^(1)[1] + Q^(2)[1]
sage: x * x
Q^(1)[1]^2 + 2*Q^(1)[1]*Q^(2)[1] + Q^(2)[1]^2
Next we do some basic computations in type `C_4`::
sage: Q = QSystem(QQ, ['C', 4])
sage: Q.Q(4,1)
Q^(4)[1]
sage: Q.Q(1,2)
Q^(1)[1]^2 - Q^(2)[1]
sage: Q.Q(3,3)
Q^(1)[1]*Q^(4)[1]^2 - 2*Q^(2)[1]*Q^(3)[1]*Q^(4)[1] + Q^(3)[1]^3
REFERENCES:
- [HKOTY1999]_
- [KNS2011]_
"""
@staticmethod
def __classcall__(cls, base_ring, cartan_type, level=None):
"""
Normalize arguments to ensure a unique representation.
EXAMPLES::
sage: Q1 = QSystem(QQ, ['A',4])
sage: Q2 = QSystem(QQ, 'A4')
sage: Q1 is Q2
True
"""
cartan_type = CartanType(cartan_type)
if not is_tamely_laced(cartan_type):
raise ValueError("the Cartan type is not tamely-laced")
return super(QSystem, cls).__classcall__(cls, base_ring, cartan_type, level)
def __init__(self, base_ring, cartan_type, level):
"""
Initialize ``self``.
EXAMPLES::
sage: Q = QSystem(QQ, ['A',2])
sage: TestSuite(Q).run()
"""
self._cartan_type = cartan_type
self._level = level
indices = tuple(itertools.product(cartan_type.index_set(), [1]))
basis = IndexedFreeAbelianMonoid(indices, prefix='Q', bracket=False)
# This is used to do the reductions
self._poly = PolynomialRing(ZZ, ['q'+str(i) for i in cartan_type.index_set()])
category = Algebras(base_ring).Commutative().WithBasis()
CombinatorialFreeModule.__init__(self, base_ring, basis,
#.........这里部分代码省略.........
示例11: product_on_basis
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
def product_on_basis(self, left, right):
r"""
Return ``left`` multiplied by ``right`` in ``self``.
EXAMPLES::
sage: R = algebras.RationalCherednik(['A',2], 1, 1, QQ)
sage: a2 = R.algebra_generators()['a2']
sage: ac1 = R.algebra_generators()['ac1']
sage: a2 * ac1 # indirect doctest
a2*ac1
sage: ac1 * a2
-I + a2*ac1 - s1 - s2 + 1/2*s1*s2*s1
sage: x = R.an_element()
sage: [y * x for y in R.some_elements()]
[0,
3*ac1 + 2*s1 + a1,
9*ac1^2 + 10*I + 6*a1*ac1 + 6*s1 + 3/2*s2 + 3/2*s1*s2*s1 + a1^2,
3*a1*ac1 + 2*a1*s1 + a1^2,
3*a2*ac1 + 2*a2*s1 + a1*a2,
3*s1*ac1 + 2*I - a1*s1,
3*s2*ac1 + 2*s2*s1 + a1*s2 + a2*s2,
3*ac1^2 - 2*s1*ac1 + 2*I + a1*ac1 + 2*s1 + 1/2*s2 + 1/2*s1*s2*s1,
3*ac1*ac2 + 2*s1*ac1 + 2*s1*ac2 - I + a1*ac2 - s1 - s2 + 1/2*s1*s2*s1]
sage: [x * y for y in R.some_elements()]
[0,
3*ac1 + 2*s1 + a1,
9*ac1^2 + 10*I + 6*a1*ac1 + 6*s1 + 3/2*s2 + 3/2*s1*s2*s1 + a1^2,
6*I + 3*a1*ac1 + 6*s1 + 3/2*s2 + 3/2*s1*s2*s1 - 2*a1*s1 + a1^2,
-3*I + 3*a2*ac1 - 3*s1 - 3*s2 + 3/2*s1*s2*s1 + 2*a1*s1 + 2*a2*s1 + a1*a2,
-3*s1*ac1 + 2*I + a1*s1,
3*s2*ac1 + 3*s2*ac2 + 2*s1*s2 + a1*s2,
3*ac1^2 + 2*s1*ac1 + a1*ac1,
3*ac1*ac2 + 2*s1*ac2 + a1*ac2]
"""
# Make copies of the internal dictionaries
dl = dict(left[2]._monomial)
dr = dict(right[0]._monomial)
# If there is nothing to commute
if not dl and not dr:
return self.monomial((left[0], left[1] * right[1], right[2]))
R = self.base_ring()
I = self._cartan_type.index_set()
P = PolynomialRing(R, 'x', len(I))
G = P.gens()
gens_dict = {a:G[i] for i,a in enumerate(I)}
Q = RootSystem(self._cartan_type).root_lattice()
alpha = Q.simple_roots()
alphacheck = Q.simple_coroots()
def commute_w_hd(w, al): # al is given as a dictionary
ret = P.one()
for k in al:
x = sum(c * gens_dict[i] for i,c in alpha[k].weyl_action(w))
ret *= x**al[k]
ret = ret.dict()
for k in ret:
yield (self._hd({I[i]: e for i,e in enumerate(k) if e != 0}), ret[k])
# Do Lac Ra if they are both non-trivial
if dl and dr:
il = dl.keys()[0]
ir = dr.keys()[0]
# Compute the commutator
terms = self._product_coroot_root(il, ir)
# remove the generator from the elements
dl[il] -= 1
if dl[il] == 0:
del dl[il]
dr[ir] -= 1
if dr[ir] == 0:
del dr[ir]
# We now commute right roots past the left reflections: s Ra = Ra' s
cur = self._from_dict({ (hd, s*right[1], right[2]): c * cc
for s,c in terms
for hd, cc in commute_w_hd(s, dr) })
cur = self.monomial( (left[0], left[1], self._h(dl)) ) * cur
# Add back in the commuted h and hd elements
rem = self.monomial( (left[0], left[1], self._h(dl)) )
rem = rem * self.monomial( (self._hd({ir:1}), self._weyl.one(),
self._h({il:1})) )
rem = rem * self.monomial( (self._hd(dr), right[1], right[2]) )
return cur + rem
if dl:
# We have La Ls Lac Rs Rac,
# so we must commute Lac Rs = Rs Lac'
# and obtain La (Ls Rs) (Lac' Rac)
ret = P.one()
for k in dl:
x = sum(c * gens_dict[i]
for i,c in alphacheck[k].weyl_action(right[1].reduced_word(),
inverse=True))
#.........这里部分代码省略.........
示例12: TestLogarithmicDifferentialForm
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
#.........这里部分代码省略.........
logdf = LogarithmicDifferentialForm(2,[self.x,self.y,self.z],self.normal_logdf)
form = DifferentialForm(self.normal_logdf.form_space,2)
form[0,1] = -5/(y*z)
form[0,2] = -5/(x*z)
form[1,2] = -5/(x*y)
self.assertTrue((logdf*(-5)).equals((-5)*logdf))
logdf_mul = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
self.assertTrue((-5*logdf).equals(logdf_mul))
def test_wedge(self):
x = self.normal_logdf.form_vars[0]
y = self.normal_logdf.form_vars[1]
z = self.normal_logdf.form_vars[2]
norm = self.x*self.y*self.z
logdfA = LogarithmicDifferentialForm(1,[self.x*norm,self.y*norm,self.z*norm],self.normal_logdf)
logdfB = LogarithmicDifferentialForm(1,[self.z,self.y,self.x],self.normal_logdf)
form = DifferentialForm(self.normal_logdf.form_space,2)
form[0,1] = 1/z - 1/x
form[0,2] = (x/(y*z)) - (z/(x*y))
form[1,2] = 1/z - 1/x
logdf_wedge = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
self.assertTrue(logdf_wedge.equals(logdfA.wedge(logdfB)))
def test_derivative(self):
x = self.x
y = self.y
z = self.z
logdf = LogarithmicDifferentialForm(1,[y*z,x*z,x*y],self.normal_logdf)
form = DifferentialForm(self.normal_logdf.form_space,2)
logdf_der = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
self.assertTrue(logdf_der.equals(logdf.derivative()))
def test_unit(self):
one = LogarithmicDifferentialForm.make_unit(self.normal_logdf)
form = DifferentialForm(self.normal_logdf.form_space,0,1)
one_form = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
self.assertTrue(one.equals(one_form))
def test_zero_p(self):
size = [1,3,3,1]
for s,i in zip(size,range(4)):
zero = LogarithmicDifferentialForm.make_zero(i,self.normal_logdf)
zero_vec = [self.normal_logdf.poly_ring.zero() for _ in range(s)]
self.assertEqual(zero.vec,zero_vec)
def test_create_from_form(self):
x = self.normal_logdf.form_vars[0]
y = self.normal_logdf.form_vars[1]
z = self.normal_logdf.form_vars[2]
xp = self.x
yp = self.y
zp = self.z
logdf = LogarithmicDifferentialForm(2,[xp*yp-yp*zp,xp**2-zp**2,xp*yp-yp*zp],self.normal_logdf)
form = DifferentialForm(self.normal_logdf.form_space,2)
form[0,1] = 1/z - 1/x
form[0,2] = (x/(y*z)) - (z/(x*y))
form[1,2] = 1/z - 1/x
logdf_form = LogarithmicDifferentialForm.create_from_form(form,self.normal_logdf)
self.assertTrue(logdf.equals(logdf_form))
def test_create_from_0_form(self):
x = self.normal_logdf.form_vars[0]
y = self.normal_logdf.form_vars[1]
z = self.normal_logdf.form_vars[2]
xp = self.x
yp = self.y
示例13: TestLogartihmicDifferentialForms
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import one [as 别名]
class TestLogartihmicDifferentialForms(unittest.TestCase):
def setUp(self):
self.poly_ring = PolynomialRing(QQ,"x",3);
self.x = self.poly_ring.gens()[0];
self.y = self.poly_ring.gens()[1];
self.z = self.poly_ring.gens()[2];
self.vars = var('x,y,z')
def test_p_forms_crossing_ngens(self):
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
self.assertEqual(len(logdf.p_form_generators(0)),1)
self.assertEqual(len(logdf.p_form_generators(1)),3)
self.assertEqual(len(logdf.p_form_generators(2)),3)
self.assertEqual(len(logdf.p_form_generators(3)),1)
def test_0_modules_crossing_ngens(self):
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
crossing_0_module = SingularModule([[crossing]])
self.assertTrue(crossing_0_module.equals(logdf.p_module(0)))
def test_1_modules_crossing_ngens(self):
x = self.x
y = self.y
z = self.z
zero = self.poly_ring.zero()
crossing = x*y*z
logdf = LogarithmicDifferentialForms(crossing)
crossing_1_module = SingularModule([[y*z,zero,zero],[zero,x*z,zero],[zero,zero,x*y]])
self.assertTrue(crossing_1_module.equals(logdf.p_module(1)))
def test_2_modules_crossing_ngens(self):
x = self.x
y = self.y
z = self.z
zero = self.poly_ring.zero()
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
crossing_2_module = SingularModule([[z,zero,zero],[zero,y,zero],[zero,zero,x]])
self.assertTrue(crossing_2_module.equals(logdf.p_module(2)))
def test_3_modules_crossing_ngens(self):
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
crossing_3_module = SingularModule([[self.poly_ring.one()]])
self.assertTrue(crossing_3_module.equals(logdf.p_module(3)))
def test_p_module_n_crossing(self):
#Make sure this doesnt throw an error - fix bug
for i in range(4,5):
p_ring = PolynomialRing(QQ,i,"z")
crossing = p_ring.one()
for g in p_ring.gens():
crossing *= g
logdf = LogarithmicDifferentialForms(crossing)
logdf.p_module(i-1)
def test_complement_complex_crossing(self):
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
complex = logdf.chain_complex("complement")
complex_size = {}
for i,c in complex.iteritems():
complex_size[i] = len(c)
self.assertEqual(complex_size,{0:1,1:3,2:3,3:1})
def test_complement_complex_whitney(self):
whitney = self.x**2*self.y - self.z**2
logdf = LogarithmicDifferentialForms(whitney)
complex = logdf.chain_complex("complement")
complex_size = {}
for i,c in complex.iteritems():
complex_size[i] = len(c)
self.assertEqual(complex_size,{0:1,1:1,2:0,3:0})
def test_equi_complex_crossing(self):
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
complex = logdf.chain_complex("equivarient")
complex_size = {}
for i,c in complex.iteritems():
complex_size[i] = len(c)
self.assertEqual(complex_size,{0:1,1:3,2:4,3:4})
def test_equi_complex_whitney(self):
whitney = self.x**2*self.y - self.z**2
logdf = LogarithmicDifferentialForms(whitney)
complex = logdf.chain_complex("equivarient")
complex_size = {}
for i,c in complex.iteritems():
complex_size[i] = len(c)
self.assertEqual(complex_size,{0:1,1:1,2:1,3:1})
def test_complement_homology_crossing(self):
crossing = self.x*self.y*self.z
logdf = LogarithmicDifferentialForms(crossing)
homology = logdf.homology("complement")
homology_size = {}
#.........这里部分代码省略.........