本文整理汇总了Python中tableau.Tableau类的典型用法代码示例。如果您正苦于以下问题:Python Tableau类的具体用法?Python Tableau怎么用?Python Tableau使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tableau类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: e_hat
def e_hat(tab, star=0):
"""
The Young projection operator, an idempotent in the rational group algebra.
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import e_hat
sage: e_hat([[1,2,3]])
1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
sage: e_hat([[1],[2]])
1/2*[1, 2] - 1/2*[2, 1]
There are differing conventions for the order of the symmetrizers
and antisymmetrizers. This example illustrates our conventions::
sage: e_hat([[1,2],[3]])
1/3*[1, 2, 3] + 1/3*[2, 1, 3] - 1/3*[3, 1, 2] - 1/3*[3, 2, 1]
"""
t = Tableau(tab)
if star:
t = t.restrict(t.size()-star)
if t in ehat_cache:
res = ehat_cache[t]
else:
res = (1/kappa(t.shape()))*e(t)
return res
示例2: e_hat
def e_hat(tab, star=0):
"""
The Young projection operator corresponding to the Young tableau
``tab`` (which is supposed to contain every integer from `1` to
its size precisely once, but may and may not be standard). This
is an idempotent in the rational group algebra.
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import e_hat
sage: e_hat([[1,2,3]])
1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
sage: e_hat([[1],[2]])
1/2*[1, 2] - 1/2*[2, 1]
There are differing conventions for the order of the symmetrizers
and antisymmetrizers. This example illustrates our conventions::
sage: e_hat([[1,2],[3]])
1/3*[1, 2, 3] + 1/3*[2, 1, 3] - 1/3*[3, 1, 2] - 1/3*[3, 2, 1]
"""
t = Tableau(tab)
if star:
t = t.restrict(t.size()-star)
if t in ehat_cache:
res = ehat_cache[t]
else:
res = (1/kappa(t.shape()))*e(t)
return res
示例3: b
def b(tableau, star=0):
r"""
The column projection operator corresponding to the Young tableau
``tableau`` (which is supposed to contain every integer from
`1` to its size precisely once, but may and may not be standard).
This is the signed sum (in the group algebra of the relevant
symmetric group over `\QQ`) of all the permutations which
preserve the column of ``tableau`` (where the signs are the usual
signs of the permutations). It is called `b_{\text{tableau}}` in
[EtRT]_, Section 4.2.
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import b
sage: b([[1,2]])
[1, 2]
sage: b([[1],[2]])
[1, 2] - [2, 1]
sage: b([])
[]
sage: b([[1, 2, 4], [5, 3]])
[1, 2, 3, 4, 5] - [1, 3, 2, 4, 5] - [5, 2, 3, 4, 1] + [5, 3, 2, 4, 1]
With the `l2r` setting for multiplication, the unnormalized
Young symmetrizer ``e(tableau)`` should be the product
``b(tableau) * a(tableau)`` for every ``tableau``. Let us check
this on the standard tableaux of size 5::
sage: from sage.combinat.symmetric_group_algebra import a, b, e
sage: all( e(t) == b(t) * a(t) for t in StandardTableaux(5) )
True
"""
t = Tableau(tableau)
if star:
t = t.restrict(t.size()-star)
cs = t.column_stabilizer().list()
n = t.size()
# This all should be over ZZ, not over QQ, but symmetric group
# algebras don't seem to preserve coercion (the one over ZZ
# doesn't coerce into the one over QQ even for the same n),
# and the QQ version of this method is more important, so let
# me stay with QQ.
# TODO: Fix this.
sgalg = SymmetricGroupAlgebra(QQ, n)
one = QQ.one()
P = permutation.Permutation
# Ugly hack for the case of an empty tableau, due to the
# annoyance of Permutation(Tableau([]).row_stabilizer()[0])
# being [1] rather than [] (which seems to have its origins in
# permutation group code).
# TODO: Fix this.
if len(tableau) == 0:
return sgalg.one()
cd = dict((P(v), v.sign()*one) for v in cs)
return sgalg._from_dict(cd)
示例4: GenRegionVoronoi
class GenRegionVoronoi(GenRegion):
def __init__(self, largeur, hauteur, nb=10):
GenRegion.__init__(self, nb)
self.tab = Tableau(largeur, hauteur)
for x, y in self.tab.iterC():
self.tab[x, y] = Case(x, y)
self.tab[x, y].value = -1
self.init = []
self.liste = [elt for elt in self.tab.iterB()]
for i in range(nb):
case = self.tab[self.liste[randrange(len(self.liste))]]
case.value = i
self.init.append(case)
self.regions.append(Region(nb, interieur=[case]))
for case in self.tab.values():
distance = self.tab.X * self.tab.Y
id = -1
for init in self.init:
if case.Distance(init) < distance:
distance = case.Distance(init)
id = init.value
case.value = id
voisins = [
self.tab[elt]
for elt in case.Voisins()
if elt in self.tab and self.tab[elt].value != -1 and self.tab[elt].value != id
]
if len(voisins):
self.regions[id].addFro(case)
for elt in voisins:
if elt in self.regions[id].interieur:
self.regions[id].interieur.remove(elt)
self.regions[id].addFro(elt)
else:
self.regions[id].addInt(case)
示例5: a
def a(tableau, star=0):
r"""
The row projection operator corresponding to the Young tableau
``tableau`` (which is supposed to contain every integer from
`1` to its size precisely once, but may and may not be standard).
This is the sum (in the group algebra of the relevant symmetric
group over `\QQ`) of all the permutations which preserve
the rows of ``tableau``. It is called `a_{\text{tableau}}` in
[EtRT]_, Section 4.2.
REFERENCES:
.. [EtRT] Pavel Etingof, Oleg Golberg, Sebastian Hensel, Tiankai
Liu, Alex Schwendner, Dmitry Vaintrob, Elena Yudovina,
"Introduction to representation theory",
:arXiv:`0901.0827v5`.
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import a
sage: a([[1,2]])
[1, 2] + [2, 1]
sage: a([[1],[2]])
[1, 2]
sage: a([])
[]
sage: a([[1, 5], [2, 3], [4]])
[1, 2, 3, 4, 5] + [1, 3, 2, 4, 5] + [5, 2, 3, 4, 1] + [5, 3, 2, 4, 1]
"""
t = Tableau(tableau)
if star:
t = t.restrict(t.size()-star)
rs = t.row_stabilizer().list()
n = t.size()
# This all should be over ZZ, not over QQ, but symmetric group
# algebras don't seem to preserve coercion (the one over ZZ
# doesn't coerce into the one over QQ even for the same n),
# and the QQ version of this method is more important, so let
# me stay with QQ.
# TODO: Fix this.
sgalg = SymmetricGroupAlgebra(QQ, n)
one = QQ.one()
P = permutation.Permutation
# Ugly hack for the case of an empty tableau, due to the
# annoyance of Permutation(Tableau([]).row_stabilizer()[0])
# being [1] rather than [] (which seems to have its origins in
# permutation group code).
# TODO: Fix this.
if len(tableau) == 0:
return sgalg.one()
rd = dict((P(h), one) for h in rs)
return sgalg._from_dict(rd)
示例6: __init__
class Seed:
def __init__(self,largeur,hauteur,noeud = {"type" : "plaque"},minValue = 0,maxValue = 255, value = 0):
self.function = {"rand" : self.rand, "degrade" : self.degrade, "plaque" : self.plaque}
self.maxValue = maxValue
self.minValue = minValue
self.X = largeur
self.Y = hauteur
self.tab = Tableau(self.X,self.Y)
if "args" in noeud:
self.function[noeud["type"]](noeud["args"])
else :
self.function[noeud["type"]]()
def degrade(self,args = {"direction":"Y","evolution":"increase"}):
if args["direction"] == "Y":
c = self.Y
current = lambda x,y : y
else:
c = self.X
current = lambda x,y : x - self.ligne(y)
if args["evolution"] == "increase":
fun = lambda x,y : self.maxValue * current(x,y) // c
elif args["evolution"] == "decrease":
fun = lambda x,y : self.maxValue * (c - (1 + current(x,y))) // c
elif args["evolution"] == "center":
fun = lambda x,y : min(self.maxValue * current(x,y) // c,self.maxValue * (c - (1 + current(x,y))) //c) * 2
elif args["evolution"] == "border":
fun = lambda x,y : max(self.maxValue * current(x,y) // c,self.maxValue * (c - (1 + current(x,y))) //c) - ( self.maxValue // 2) * 2
for(x,y) in self.tab.iterC():
self.tab[x,y] = Case(x,y)
self.tab[x,y].value = fun(x,y)
def rand(self,args = {}):
for(x,y) in self.tab.iterC():
self.tab[x,y] = Case(x,y)
self.tab[x,y].value = randint(self.minValue,self.maxValue)
def plaque(self,args = {"nombre" : 5, "plaques" : 8}):
for x,y in self.tab.iterC():
self.tab[x,y] = Case(x,y)
self.tab[x,y].value = 0
liste = [ elt for elt in self.tab.iterB(1) ]
nombre = args["nombre"]
plaque = args["plaques"]
plaques = GenRegionPasse(self.tab,None,plaque,5)
plaques.finalisation()
liste_plaque = [ (elt.interieur,elt.frontiere) for elt in plaques.regions]
for i in range(nombre):
li,lf = liste_plaque[randrange(len(liste_plaque))]
liste_plaque.remove((li,lf))
for elt in [ (elt.u,elt.v) for elt in li if (elt.u,elt.v) in liste]:
#self.tab[elt].value = randint((self.minValue + self.maxValue) * 3 // 4 , self.maxValue )
self.tab[elt].value = int(((plaques.iteration - self.tab[elt].nb + 1) / plaques.iteration)* self.maxValue)
示例7: epsilon_ik
def epsilon_ik(itab, ktab, star=0):
"""
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import epsilon_ik
sage: epsilon_ik([[1,2],[3]], [[1,3],[2]])
1/4*[1, 3, 2] - 1/4*[2, 3, 1] + 1/4*[3, 1, 2] - 1/4*[3, 2, 1]
sage: epsilon_ik([[1,2],[3]], [[1,3],[2]], star=1)
Traceback (most recent call last):
...
ValueError: the two tableaux must be of the same shape
"""
it = Tableau(itab)
kt = Tableau(ktab)
if star:
it = it.restrict(it.size() - star)
kt = kt.restrict(kt.size() - star)
if it.shape() != kt.shape():
raise ValueError, "the two tableaux must be of the same shape"
mult = permutation_options['mult']
permutation_options['mult'] = 'l2r'
if kt == it:
res = epsilon(itab)
elif (it, kt) in epsilon_ik_cache:
res = epsilon_ik_cache[(it,kt)]
else:
epsilon_ik_cache[(it,kt)] = epsilon(it, star+1)*e_ik(it,kt,star)*epsilon(kt, star+1) * (1/kappa(it.shape()))
res = epsilon_ik_cache[(it,kt)]
permutation_options['mult'] = mult
return res
示例8: e_ik
def e_ik(itab, ktab, star=0):
"""
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import e_ik
sage: e_ik([[1,2,3]], [[1,2,3]])
[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
sage: e_ik([[1,2,3]], [[1,2,3]], star=1)
[1, 2] + [2, 1]
"""
it = Tableau(itab)
kt = Tableau(ktab)
if star:
it = it.restrict(it.size() - star)
kt = kt.restrict(kt.size() - star)
if it.shape() != kt.shape():
raise ValueError, "the two tableaux must be of the same shape"
mult = permutation_options['mult']
permutation_options['mult'] = 'l2r'
if kt == it:
res = e(it)
elif (it, kt) in e_ik_cache:
res = e_ik_cache[(it,kt)]
else:
pi = pi_ik(it,kt)
e_ik_cache[(it,kt)] = e(it)*pi
res = e_ik_cache[(it,kt)]
permutation_options['mult'] = mult
return res
示例9: __init__
def __init__(self, strategy, visual=False, screen=None):
S = getattr(strategies, strategy)
strategy = S()
self.tableau = Tableau()
self.redeals = 2
self.strategy = strategy
self.visual = visual
self.screen = screen
示例10: Game
class Game(object):
def __init__(self, strategy, visual=False, screen=None):
S = getattr(strategies, strategy)
strategy = S()
self.tableau = Tableau()
self.redeals = 2
self.strategy = strategy
self.visual = visual
self.screen = screen
def play(self):
while True:
while self.tableau.has_moves():
if self.visual and self.screen:
self.screen.addstr(1,0,self.tableau.dump().encode("utf_8"))
self.screen.refresh()
self.strategy.apply_strategy(self.tableau)
if self.visual and self.screen:
self.screen.getch()
if not self.tableau.is_complete() and self.redeals > 0:
self.tableau.redeal()
self.redeals -= 1
else:
break
def in_progress(self):
return self.tableau.has_moves()
def game_won(self):
return self.tableau.is_complete()
示例11: setUp
def setUp(self):
# variables
pre_var = [(0, True), (0, False), (0, False), (0, True), (0, True)]
self.vars = [Variable(*v) for v in pre_var]
# row lines
pre_row = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, -1, 0, 0],
[2, -1, 0, -1, 0], [-1, 2, 0, 0, -1]]
self.rows = [RowLine(r) for r in pre_row]
# tableau
self.table = Tableau(self.vars, self.rows)
示例12: pi_ik
def pi_ik(itab, ktab):
"""
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import pi_ik
sage: pi_ik([[1,3],[2]], [[1,2],[3]])
[1, 3, 2]
"""
it = Tableau(itab)
kt = Tableau(ktab)
p = [None]*kt.size()
for i in range(len(kt)):
for j in range(len(kt[i])):
p[ it[i][j] -1 ] = kt[i][j]
QSn = SymmetricGroupAlgebra(QQ, it.size())
p = permutation.Permutation(p)
return QSn(p)
示例13: __init__
def __init__(self, largeur, hauteur, modele): # X,Y,Liste_Coeff
self.X = largeur
self.Y = hauteur
self.MAXVALUE = 256
self.tab = Tableau(self.X, self.Y)
self.modele = Modele("patron.xml")
self.seed = [(key, Seed(self.X, self.Y, elt["seed"])) for key, elt in self.modele.racine["couche"].items()]
for x, y in self.tab.iterC():
self.tab[x, y] = Case(x, y)
for key, s in self.seed:
self.tab[x, y].biome.set(key, s.tab[x, y].value)
示例14: Test
class Test(unittest.TestCase):
def setUp(self):
# variables
pre_var = [(0, True), (0, False), (0, False), (0, True), (0, True)]
self.vars = [Variable(*v) for v in pre_var]
# row lines
pre_row = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, -1, 0, 0],
[2, -1, 0, -1, 0], [-1, 2, 0, 0, -1]]
self.rows = [RowLine(r) for r in pre_row]
# tableau
self.table = Tableau(self.vars, self.rows)
def tearDown(self):
pass
# tests about operators to help Gaussian elimination
def test_row_subtraction(self):
t_sub = self.rows[3] - self.rows[2]
self.assertListEqual(t_sub.coef, [1, -2, 1, -1, 0])
def test_row_multiplication(self):
t_mul = self.rows[4] * 3
self.assertListEqual(t_mul.coef, [-3, 6, 0, 0, -3])
def test_row_division(self):
t_div = self.rows[2] / 5
self.assertListEqual(t_div.coef, [0.2, 0.2, -0.2, 0, 0])
def test_getitem(self):
# originally, this operation should be written self.rows[2].coef[0]
# RowLine has __getitem__ method, so this abbreviation is able
self.assertEqual(self.rows[2][0], 1)
# main test
def test_gaussian_elimination(self):
self.table.gaussian_elimination(2, 0)
coef = [r.coef for r in self.table.rows]
self.assertListEqual(coef, [[-1, -1, 1, 0, 0], [0, 0, 0, 0, 0],
[1, 1, -1, 0, 0], [0, -3, 2, -1, 0],
[0, 3, -1, 0, -1]])
示例15: epsilon
def epsilon(tab, star=0):
"""
EXAMPLES::
sage: from sage.combinat.symmetric_group_algebra import epsilon
sage: epsilon([[1,2]])
1/2*[1, 2] + 1/2*[2, 1]
sage: epsilon([[1],[2]])
1/2*[1, 2] - 1/2*[2, 1]
"""
t = Tableau(tab)
if star:
t = t.restrict(t.size() - star)
mult = permutation_options['mult']
permutation_options['mult'] = 'l2r'
if t in epsilon_cache:
res = epsilon_cache[t]
else:
if t.size() == 2:
epsilon_cache[t] = e(t)*(1/kappa(t.shape()))
res = epsilon_cache[t]
elif t == Tableau([[1]]):
epsilon_cache[t] = e(t)
res = epsilon_cache[t]
else:
epsilon_cache[t] = epsilon(t, 1)*e(t)*epsilon(t,1)*( 1 / kappa(t.shape()))
res = epsilon_cache[t]
permutation_options['mult'] = mult
return res