本文整理汇总了Python中sage.categories.tensor.tensor函数的典型用法代码示例。如果您正苦于以下问题:Python tensor函数的具体用法?Python tensor怎么用?Python tensor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tensor函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: coproduct_by_coercion
def coproduct_by_coercion(self, elt):
r"""
Returns the coproduct of the element ``elt`` by coercion to the Schur basis.
INPUT:
- ``elt`` -- an instance of the ``Qp`` basis
OUTPUT:
- The coproduct acting on ``elt``, the result is an element of the
tensor squared of the ``Qp`` symmetric function basis
EXAMPLES::
sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())
sage: JQp = Sym.jack().Qp()
sage: JQp[2,2].coproduct() #indirect doctest
JackQp[] # JackQp[2, 2] + (2*t/(t+1))*JackQp[1] # JackQp[2, 1] + JackQp[1, 1] # JackQp[1, 1] + ((4*t^3+8*t^2)/(2*t^3+5*t^2+4*t+1))*JackQp[2] # JackQp[2] + (2*t/(t+1))*JackQp[2, 1] # JackQp[1] + JackQp[2, 2] # JackQp[]
"""
h = elt.parent().realization_of().h()
parent = elt.parent()
from sage.categories.tensor import tensor
cfunc = lambda x, y: tensor([parent(x), parent(y)])
cprod = h(elt).coproduct().apply_multilinear_morphism(cfunc)
normalize = lambda c: normalize_coefficients(parent, c)
return cprod.parent().sum(normalize(coeff) * tensor([parent(x), parent(y)]) for ((x, y), coeff) in cprod)
开发者ID:imark83,项目名称:sage,代码行数:28,代码来源:jack.py
示例2: coproduct
def coproduct(self):
r"""
Returns the coproduct operation on ``self``.
The coproduct is first computed on the homogeneous basis if `t=1` and
on the Hall-Littlewood ``Qp`` basis otherwise. The result is computed
then converted to the tensor squared of ``self.parent()``
EXAMPLES::
sage: Sym = SymmetricFunctions(QQ)
sage: ks3 = Sym.kschur(3,1)
sage: ks3[2,1].coproduct()
ks3[] # ks3[2, 1] + ks3[1] # ks3[1, 1] + ks3[1] # ks3[2] + ks3[1, 1] # ks3[1] + ks3[2] # ks3[1] + ks3[2, 1] # ks3[]
sage: h3 = Sym.khomogeneous(3)
sage: h3[2,1].coproduct()
h3[] # h3[2, 1] + h3[1] # h3[1, 1] + h3[1] # h3[2] + h3[1, 1] # h3[1] + h3[2] # h3[1] + h3[2, 1] # h3[]
sage: ks3t = SymmetricFunctions(FractionField(QQ['t'])).kschur(3)
sage: ks3t[2,1].coproduct()
ks3[] # ks3[2, 1] + ks3[1] # ks3[1, 1] + ks3[1] # ks3[2] + ks3[1, 1] # ks3[1] + ks3[2] # ks3[1] + ks3[2, 1] # ks3[]
sage: ks3t[3,1].coproduct()
ks3[] # ks3[3, 1] + ks3[1] # ks3[2, 1] + (t+1)*ks3[1] # ks3[3] + ks3[1, 1] # ks3[2] + ks3[2] # ks3[1, 1]
+ (t+1)*ks3[2] # ks3[2] + ks3[2, 1] # ks3[1] + (t+1)*ks3[3] # ks3[1] + ks3[3, 1] # ks3[]
"""
lifted = self.lift()
target_basis = self.parent()
ambient = self.parent().realization_of().ambient()
t = self.parent().realization_of().t
if t==1:
source_basis = ambient.h()
else:
source_basis = ambient.hall_littlewood(t=t).Qp()
cpfunc = lambda x,y: tensor([ target_basis(x), target_basis(y) ])
return source_basis(lifted).coproduct().apply_multilinear_morphism( cpfunc )
开发者ID:chos9,项目名称:sage,代码行数:34,代码来源:new_kschur.py
示例3: coproduct_by_coercion
def coproduct_by_coercion(self, x):
r"""
Returns the coproduct by coercion if coproduct_by_basis is not implemented.
EXAMPLES::
sage: Sym = SymmetricFunctions(QQ)
sage: m = Sym.monomial()
sage: f = m[2,1]
sage: f.coproduct.__module__
'sage.categories.coalgebras'
sage: m.coproduct_on_basis
NotImplemented
sage: m.coproduct == m.coproduct_by_coercion
True
sage: f.coproduct()
m[] # m[2, 1] + m[1] # m[2] + m[2] # m[1] + m[2, 1] # m[]
::
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: R = N.ribbon()
sage: R.coproduct_by_coercion.__module__
'sage.categories.coalgebras'
sage: R.coproduct_on_basis
NotImplemented
sage: R.coproduct == R.coproduct_by_coercion
True
sage: R[1].coproduct()
R[] # R[1] + R[1] # R[]
"""
from sage.categories.tensor import tensor
R = self.realization_of().a_realization()
return self.tensor_square().sum(coeff * tensor([self(R[I]), self(R[J])])
for ((I, J), coeff) in R(x).coproduct())
开发者ID:sageb0t,项目名称:testsage,代码行数:35,代码来源:coalgebras.py
示例4: product_on_basis
def product_on_basis(self, t1, t2):
"""
The product of the algebra on the basis, as per
``AlgebrasWithBasis.ParentMethods.product_on_basis``.
EXAMPLES::
sage: A = AlgebrasWithBasis(QQ).example(); A
An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
sage: (a,b,c) = A.algebra_generators()
sage: x = tensor( (a, b, c) ); x
B[word: a] # B[word: b] # B[word: c]
sage: y = tensor( (c, b, a) ); y
B[word: c] # B[word: b] # B[word: a]
sage: x*y
B[word: ac] # B[word: bb] # B[word: ca]
sage: x = tensor( ((a+2*b), c) ) ; x
B[word: a] # B[word: c] + 2*B[word: b] # B[word: c]
sage: y = tensor( (c, a) ) + 1; y
B[word: ] # B[word: ] + B[word: c] # B[word: a]
sage: x*y
B[word: a] # B[word: c] + B[word: ac] # B[word: ca] + 2*B[word: b] # B[word: c] + 2*B[word: bc] # B[word: ca]
TODO: optimize this implementation!
"""
return tensor( (module.monomial(x1)*module.monomial(x2) for (module, x1, x2) in zip(self._sets, t1, t2)) ) #.
开发者ID:sageb0t,项目名称:testsage,代码行数:28,代码来源:algebras_with_basis.py
示例5: tensor_square
def tensor_square(self):
"""
Returns the tensor square of ``self``
EXAMPLES::
sage: A = HopfAlgebrasWithBasis(QQ).example()
sage: A.tensor_square()
An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field # An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
"""
return tensor([self, self])
开发者ID:sageb0t,项目名称:testsage,代码行数:11,代码来源:coalgebras.py
示例6: antipode_on_basis
def antipode_on_basis(self, index):
r"""
The antipode on the basis element indexed by ``index``.
INPUT:
- ``index`` -- an element of the index set
For a filtered connected Hopf algebra, we can define
an antipode recursively by
.. MATH::
S(x) := -\sum_{x^L \neq x} S(x^L) \times x^R + \epsilon(x)
for all `x`, using the Sweedler notation.
Also, `S(x) = x` for all `x` with `|x| = 0`.
TESTS::
sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
sage: H.monomial(0).antipode() # indirect doctest
P0
sage: H.monomial(1).antipode() # indirect doctest
-P1
sage: H.monomial(2).antipode() # indirect doctest
P2
sage: H.monomial(3).antipode() # indirect doctest
-P3
"""
if self.monomial(index) == self.one():
return self.one()
S = self.antipode_on_basis
x__S_Id = tensor([self, self]).module_morphism(
lambda ab: S(ab[0]) * self.monomial(ab[1]),
codomain=self)
smi = self.monomial(index)
return -x__S_Id(smi.coproduct()
- tensor([smi, self.one()])
) + smi.counit()
开发者ID:saraedum,项目名称:sage-renamed,代码行数:41,代码来源:filtered_hopf_algebras_with_basis.py
示例7: coproduct
def coproduct(self, elt):
r"""
Return the coproduct of the element ``elt``.
INPUT:
- ``elt`` -- a symmetric function written in this basis
OUTPUT:
- The coproduct acting on ``elt``; the result is an element of the
tensor squared of the basis ``self``
EXAMPLES::
sage: w = SymmetricFunctions(QQ).w()
sage: w[2].coproduct()
w[] # w[2] - w[1] # w[1] + w[2] # w[]
sage: w.coproduct(w[2])
w[] # w[2] - w[1] # w[1] + w[2] # w[]
sage: w[2,1].coproduct()
w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]
sage: w.coproduct(w[2,1])
w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]
TESTS:
The same, but with other settings::
sage: w = SymmetricFunctions(QQ).w(coerce_h=False, coerce_e=True)
sage: w[2].coproduct()
w[] # w[2] - w[1] # w[1] + w[2] # w[]
sage: w.coproduct(w[2])
w[] # w[2] - w[1] # w[1] + w[2] # w[]
sage: w[2,1].coproduct()
w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]
sage: w.coproduct(w[2,1])
w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]
sage: w = SymmetricFunctions(QQ).w(coerce_h=False, coerce_p=True)
sage: w[2].coproduct()
w[] # w[2] - w[1] # w[1] + w[2] # w[]
sage: w.coproduct(w[2])
w[] # w[2] - w[1] # w[1] + w[2] # w[]
sage: w[2,1].coproduct()
w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]
sage: w.coproduct(w[2,1])
w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]
"""
from sage.categories.tensor import tensor
friendly = self._friendly
return self.tensor_square().sum(coeff * tensor([self(friendly[x]), self(friendly[y])])
for ((x,y), coeff) in friendly(elt).coproduct())
开发者ID:CETHop,项目名称:sage,代码行数:53,代码来源:witt.py
示例8: antipode_on_basis
def antipode_on_basis(self, index):
r"""
The antipode on the basis element indexed by ``index``.
INPUT:
- ``index`` -- an element of the index set
For a graded connected Hopf algebra, we can define
an antipode recursively by
.. MATH::
S(x) := -\sum_{x^L \neq x} S(x^L) \times x^R
when `|x| > 0`, and by `S(x) = x` when `|x| = 0`.
TESTS::
sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
sage: H.monomial(0).antipode() # indirect doctest
P0
sage: H.monomial(1).antipode() # indirect doctest
-P1
sage: H.monomial(2).antipode() # indirect doctest
P2
sage: H.monomial(3).antipode() # indirect doctest
-P3
"""
if self.monomial(index) == self.one():
return self.one()
S = self.antipode_on_basis
x__S_Id = tensor([self, self]).module_morphism(
lambda ab: S(ab[0]) * self.monomial(ab[1]),
codomain=self)
return -x__S_Id(
self.monomial(index).coproduct()
- tensor([self.monomial(index), self.one()])
)
开发者ID:sagemath,项目名称:sage,代码行数:40,代码来源:graded_hopf_algebras_with_basis.py
示例9: antipode_on_basis
def antipode_on_basis(self, index):
r"""
The antipode on the basis element indexed by ``index``.
INPUT:
- ``index`` -- an element of the index set
.. MATH::
S(x) := -\sum_{x^L\neq x} S(x^L) \times x^R
in general or `x` if `|x| = 0`.
TESTS::
sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
sage: H.monomial(0).antipode() #indirect doctest
P0
sage: H.monomial(1).antipode() #indirect doctest
-P1
sage: H.monomial(2).antipode() #indirect doctest
P2
sage: H.monomial(3).antipode() #indirect doctest
-P3
"""
if self.monomial(index) == self.one():
return self.one()
else:
S = self.antipode_on_basis
x__S_Id = tensor([self, self]).module_morphism(
lambda (a, b): S(a) * self.monomial(b),
codomain=self)
return -x__S_Id(
self.monomial(index).coproduct()
- tensor([self.monomial(index), self.one()])
)
开发者ID:Findstat,项目名称:sage,代码行数:38,代码来源:graded_hopf_algebras_with_basis.py
示例10: coproduct_on_basis
def coproduct_on_basis(self, g):
r"""
Returns the coproduct of the element of the basis (which are
group-like). Used to compute the coproduct of any element.
EXAMPLES::
sage: A=CyclicPermutationGroup(6).algebra(ZZ);A
Group algebra of Cyclic group of order 6 as a permutation group over Integer Ring
sage: g=CyclicPermutationGroup(6).an_element();g
(1,2,3,4,5,6)
sage: A.coproduct_on_basis(g)
B[(1,2,3,4,5,6)] # B[(1,2,3,4,5,6)]
sage: a=A.an_element();a
B[()] + 3*B[(1,2,3,4,5,6)] + 3*B[(1,3,5)(2,4,6)]
sage: a.coproduct()
B[()] # B[()] + 3*B[(1,2,3,4,5,6)] # B[(1,2,3,4,5,6)] + 3*B[(1,3,5)(2,4,6)] # B[(1,3,5)(2,4,6)]
"""
from sage.categories.tensor import tensor
g = self.term(g)
return tensor([g, g])
开发者ID:sageb0t,项目名称:testsage,代码行数:21,代码来源:groups.py
示例11: free_module
def free_module(self, d):
"""
Return the free module in degree ``d``.
EXAMPLES::
sage: SGA = SymmetricGroupAlgebra(QQ, 3)
sage: T = SGA.trivial_representation()
sage: H = SGA.hochschild_complex(T)
sage: H.free_module(0)
Trivial representation of Standard permutations of 3 over Rational Field
sage: H.free_module(1)
Trivial representation of Standard permutations of 3 over Rational Field
# Symmetric group algebra of order 3 over Rational Field
sage: H.free_module(2)
Trivial representation of Standard permutations of 3 over Rational Field
# Symmetric group algebra of order 3 over Rational Field
# Symmetric group algebra of order 3 over Rational Field
"""
if d < 0:
raise ValueError("only defined for non-negative degree")
return tensor([self._M] + [self._A]*d)
开发者ID:Babyll,项目名称:sage,代码行数:22,代码来源:hochschild_complex.py
示例12: coproduct_on_basis
def coproduct_on_basis(self, g):
r"""
Return the coproduct of the element ``g`` of the basis.
Each basis element ``g`` is group-like. This method is
used to compute the coproduct of any element.
EXAMPLES::
sage: A = CyclicPermutationGroup(6).algebra(ZZ); A
Algebra of Cyclic group of order 6 as a permutation group over Integer Ring
sage: g = CyclicPermutationGroup(6).an_element(); g
(1,2,3,4,5,6)
sage: A.coproduct_on_basis(g)
(1,2,3,4,5,6) # (1,2,3,4,5,6)
sage: a = A.an_element(); a
() + (1,2,3,4,5,6) + 3*(1,3,5)(2,4,6) + 2*(1,5,3)(2,6,4)
sage: a.coproduct()
() # () + (1,2,3,4,5,6) # (1,2,3,4,5,6) + 3*(1,3,5)(2,4,6) # (1,3,5)(2,4,6) + 2*(1,5,3)(2,6,4) # (1,5,3)(2,6,4)
"""
from sage.categories.tensor import tensor
g = self.term(g)
return tensor([g, g])
开发者ID:sagemath,项目名称:sage,代码行数:23,代码来源:group_algebras.py
示例13: convolution_product
#.........这里部分代码省略.........
sage: x.convolution_product(Id, Id)
5*[1, 2, 3] + 2*[2, 3, 1] + 2*[3, 1, 2]
sage: x.convolution_product(Id, Id, Id)
4*[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + 3*[3, 2, 1]
sage: x.convolution_product([Id]*6)
9*[1, 2, 3]
TESTS::
sage: Id = lambda x: x
sage: Antipode = lambda x: x.antipode()
::
sage: h = SymmetricFunctions(QQ).h()
sage: h[5].convolution_product([Id, Id])
2*h[3, 2] + 2*h[4, 1] + 2*h[5]
sage: h.one().convolution_product([Id, Antipode])
h[]
sage: h[3,2].convolution_product([Id, Antipode])
0
sage: h.one().convolution_product([Id, Antipode]) == h.one().convolution_product()
True
::
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: S[4].convolution_product([Id]*5)
5*S[1, 1, 1, 1] + 10*S[1, 1, 2] + 10*S[1, 2, 1] + 10*S[1, 3]
+ 10*S[2, 1, 1] + 10*S[2, 2] + 10*S[3, 1] + 5*S[4]
::
sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m()
sage: m[[1,3],[2]].convolution_product([Antipode, Antipode])
3*m{{1}, {2, 3}} + 3*m{{1, 2}, {3}} + 6*m{{1, 2, 3}} - 2*m{{1, 3}, {2}}
sage: m[[]].convolution_product([])
m{}
sage: m[[1,3],[2]].convolution_product([])
0
::
sage: QS = SymmetricGroupAlgebra(QQ, 5)
sage: x = QS.sum_of_terms(zip(Permutations(5)[3:6],[1,2,3])); x
[1, 2, 4, 5, 3] + 2*[1, 2, 5, 3, 4] + 3*[1, 2, 5, 4, 3]
sage: x.convolution_product([Antipode, Id])
6*[1, 2, 3, 4, 5]
sage: x.convolution_product(Id, Antipode, Antipode, Antipode)
3*[1, 2, 3, 4, 5] + [1, 2, 4, 5, 3] + 2*[1, 2, 5, 3, 4]
::
sage: G = SymmetricGroup(3)
sage: QG = GroupAlgebra(G,QQ)
sage: x = QG.sum_of_terms([(p,p.length()) for p in Permutations(3)]); x
[1, 3, 2] + [2, 1, 3] + 2*[2, 3, 1] + 2*[3, 1, 2] + 3*[3, 2, 1]
sage: x.convolution_product(Antipode, Id)
9*[1, 2, 3]
sage: x.convolution_product([Id, Antipode, Antipode, Antipode])
5*[1, 2, 3] + 2*[2, 3, 1] + 2*[3, 1, 2]
::
sage: s[3,2].counit().parent() == s[3,2].convolution_product().parent()
False
"""
# Be flexible on how the maps are entered: accept a list/tuple of
# maps as well as multiple arguments
if len(maps) == 1 and isinstance(maps[0], (list, tuple)):
T = tuple(maps[0])
else:
T = maps
H = self.parent()
n = len(T)
if n == 0:
return H.one() * self.counit()
if n == 1:
return T[0](self)
# We apply the maps T_i and products concurrently with coproducts, as this
# seems to be faster than applying a composition of maps, e.g., (H.nfold_product) * tensor(T) * (H.nfold_coproduct).
out = tensor((H.one(),self))
HH = tensor((H,H))
for mor in T[:-1]:
#ALGORITHM:
#`split_convolve` moves terms of the form x # y to x*Ti(y1) # y2 in Sweedler notation.
def split_convolve(x_y):
x, y = x_y
return (((xy1,y2),c*d)
for ((y1,y2),d) in H.term(y).coproduct()
for (xy1,c) in H.term(x)*mor(H.term(y1)))
out = HH.module_morphism(on_basis=lambda t: HH.sum_of_terms(split_convolve(t)), codomain=HH)(out)
#Apply final map `T_n` to last term, `y`, and multiply.
return HH.module_morphism(on_basis=lambda xy: H.term(xy[0])*T[-1](H.term(xy[1])), codomain=H)(out)
开发者ID:Babyll,项目名称:sage,代码行数:101,代码来源:bialgebras_with_basis.py
注:本文中的sage.categories.tensor.tensor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论