本文整理匯總了Python中sage.combinat.sf.sf.SymmetricFunctions.sum_of_terms方法的典型用法代碼示例。如果您正苦於以下問題:Python SymmetricFunctions.sum_of_terms方法的具體用法?Python SymmetricFunctions.sum_of_terms怎麽用?Python SymmetricFunctions.sum_of_terms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sage.combinat.sf.sf.SymmetricFunctions
的用法示例。
在下文中一共展示了SymmetricFunctions.sum_of_terms方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: to_symmetric_function
# 需要導入模塊: from sage.combinat.sf.sf import SymmetricFunctions [as 別名]
# 或者: from sage.combinat.sf.sf.SymmetricFunctions import sum_of_terms [as 別名]
def to_symmetric_function( self ):
r"""
Takes a quasi-symmetric function, expressed in the monomial basis, and
returns its symmetric realization, when possible, expressed in the
monomial basis of symmetric functions.
OUTPUT:
- If ``self`` is a symmetric function, then the expansion
in the monomial basis of the symmetric functions is returned.
Otherwise an error is raised.
EXAMPLES::
sage: QSym = QuasiSymmetricFunctions(QQ)
sage: M = QSym.Monomial()
sage: (M[3,2] + M[2,3] + M[4,1]).to_symmetric_function()
Traceback (most recent call last):
...
ValueError: M[2, 3] + M[3, 2] + M[4, 1] is not a symmetric function
sage: (M[3,2] + M[2,3] + 2*M[4,1] + 2*M[1,4]).to_symmetric_function()
m[3, 2] + 2*m[4, 1]
sage: m = SymmetricFunctions(QQ).m()
sage: M(m[3,1,1]).to_symmetric_function()
m[3, 1, 1]
sage: (M(m[2,1])*M(m[2,1])).to_symmetric_function()-m[2,1]*m[2,1]
0
TESTS::
sage: (M(0)).to_symmetric_function()
0
sage: (M([])).to_symmetric_function()
m[]
sage: (2*M([])).to_symmetric_function()
2*m[]
"""
m = SymmetricFunctions(self.parent().base_ring()).monomial()
if self.is_symmetric():
return m.sum_of_terms([(I, coeff) for (I, coeff) in self
if list(I) in Partitions()], distinct=True)
else:
raise ValueError, "%s is not a symmetric function"%self
示例2: to_symmetric_function
# 需要導入模塊: from sage.combinat.sf.sf import SymmetricFunctions [as 別名]
# 或者: from sage.combinat.sf.sf.SymmetricFunctions import sum_of_terms [as 別名]
def to_symmetric_function(self):
r"""
Return the image of ``self`` under the natural projection
map to `Sym`.
The natural projection map `FSym \to Sym` sends each
standard tableau `t` to the Schur function `s_\lambda`,
where `\lambda` is the shape of `t`.
This map is a surjective Hopf algebra homomorphism.
EXAMPLES::
sage: FSym = algebras.FSym(QQ)
sage: G = FSym.G()
sage: t = StandardTableau([[1,3],[2,4],[5]])
sage: G[t].to_symmetric_function()
s[2, 2, 1]
"""
s = SymmetricFunctions(self.parent().base_ring()).s()
return s.sum_of_terms((t.shape(), coeff) for t, coeff in self)
示例3: to_symmetric_function
# 需要導入模塊: from sage.combinat.sf.sf import SymmetricFunctions [as 別名]
# 或者: from sage.combinat.sf.sf.SymmetricFunctions import sum_of_terms [as 別名]
def to_symmetric_function(self):
r"""
Take a function in the `\mathbf{w}` basis, and return its
symmetric realization, when possible, expressed in the
homogeneous basis of symmetric functions.
OUTPUT:
- If ``self`` is a symmetric function, then the expansion
in the homogeneous basis of the symmetric functions is returned.
Otherwise an error is raised.
EXAMPLES::
sage: w = SymmetricFunctionsNonCommutingVariables(QQ).dual().w()
sage: elt = w[[1],[2,3]] + w[[1,2],[3]] + w[[1,3],[2]]
sage: elt.to_symmetric_function()
h[2, 1]
sage: elt = w.sum_of_partitions([2,1,1]) / 2
sage: elt.to_symmetric_function()
1/2*h[2, 1, 1]
TESTS::
sage: w = SymmetricFunctionsNonCommutingVariables(QQ).dual().w()
sage: w(0).to_symmetric_function()
0
sage: w([]).to_symmetric_function()
h[]
sage: (2*w([])).to_symmetric_function()
2*h[]
"""
if not self.is_symmetric():
raise ValueError("not a symmetric function")
h = SymmetricFunctions(self.parent().base_ring()).homogeneous()
d = {A.shape(): c for A, c in self}
return h.sum_of_terms(
[(AA, cc / prod(map(factorial, AA.to_exp()))) for AA, cc in d.items()], distinct=True
)
示例4: cycle_index
# 需要導入模塊: from sage.combinat.sf.sf import SymmetricFunctions [as 別名]
# 或者: from sage.combinat.sf.sf.SymmetricFunctions import sum_of_terms [as 別名]
#.........這裏部分代碼省略.........
p[1, 1, 1, 1] + 6*p[2, 1, 1] + 3*p[2, 2] + 8*p[3, 1] + 6*p[4]
If `l = (l_1,\dots,l_k)` is a partition, ``|G| P[l]`` is the number
of elements of `G` with cycles of length `(p_1,\dots,p_k)`::
sage: 24 * P[ Partition([3,1]) ]
8
The cycle index plays an important role in the enumeration of
objects modulo the action of a group (Pólya enumeration), via
the use of symmetric functions and plethysms. It is therefore
encoded as a symmetric function, expressed in the powersum
basis::
sage: P.parent()
Symmetric Functions over Rational Field in the powersum basis
This symmetric function can have some nice properties; for
example, for the symmetric group `S_n`, we get the complete
symmetric function `h_n`::
sage: S = SymmetricFunctions(QQ); h = S.h()
sage: h( P )
h[4]
.. TODO::
Add some simple examples of Pólya enumeration, once
it will be easy to expand symmetric functions on any
alphabet.
Here are the cycle indices of some permutation groups::
sage: 6 * CyclicPermutationGroup(6).cycle_index()
p[1, 1, 1, 1, 1, 1] + p[2, 2, 2] + 2*p[3, 3] + 2*p[6]
sage: 60 * AlternatingGroup(5).cycle_index()
p[1, 1, 1, 1, 1] + 15*p[2, 2, 1] + 20*p[3, 1, 1] + 24*p[5]
sage: for G in TransitiveGroups(5): # optional - database_gap # long time
....: G.cardinality() * G.cycle_index()
p[1, 1, 1, 1, 1] + 4*p[5]
p[1, 1, 1, 1, 1] + 5*p[2, 2, 1] + 4*p[5]
p[1, 1, 1, 1, 1] + 5*p[2, 2, 1] + 10*p[4, 1] + 4*p[5]
p[1, 1, 1, 1, 1] + 15*p[2, 2, 1] + 20*p[3, 1, 1] + 24*p[5]
p[1, 1, 1, 1, 1] + 10*p[2, 1, 1, 1] + 15*p[2, 2, 1] + 20*p[3, 1, 1] + 20*p[3, 2] + 30*p[4, 1] + 24*p[5]
Permutation groups with arbitrary domains are supported
(see :trac:`22765`)::
sage: G = PermutationGroup([['b','c','a']], domain=['a','b','c'])
sage: G.cycle_index()
1/3*p[1, 1, 1] + 2/3*p[3]
One may specify another parent for the result::
sage: F = CombinatorialFreeModule(QQ, Partitions())
sage: P = CyclicPermutationGroup(6).cycle_index(parent = F)
sage: 6 * P
B[[1, 1, 1, 1, 1, 1]] + B[[2, 2, 2]] + 2*B[[3, 3]] + 2*B[[6]]
sage: P.parent() is F
True
This parent should be a module with basis indexed by partitions::
sage: CyclicPermutationGroup(6).cycle_index(parent = QQ)
Traceback (most recent call last):
...
ValueError: `parent` should be a module with basis indexed by partitions
REFERENCES:
- [Ke1991]_
AUTHORS:
- Nicolas Borie and Nicolas M. Thiéry
TESTS::
sage: P = PermutationGroup([]); P
Permutation Group with generators [()]
sage: P.cycle_index()
p[1]
sage: P = PermutationGroup([[(1)]]); P
Permutation Group with generators [()]
sage: P.cycle_index()
p[1]
"""
from sage.categories.modules import Modules
if parent is None:
from sage.rings.rational_field import QQ
from sage.combinat.sf.sf import SymmetricFunctions
parent = SymmetricFunctions(QQ).powersum()
elif not parent in Modules.WithBasis:
raise ValueError("`parent` should be a module with basis indexed by partitions")
base_ring = parent.base_ring()
return parent.sum_of_terms([C.an_element().cycle_type(), base_ring(C.cardinality())]
for C in self.conjugacy_classes()
) / self.cardinality()