chore: 添加虚拟环境到仓库
- 添加 backend_service/venv 虚拟环境 - 包含所有Python依赖包 - 注意:虚拟环境约393MB,包含12655个文件
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
|
||||
__all__ = ['CartanType']
|
||||
@@ -0,0 +1,25 @@
|
||||
from .cartan_type import CartanType
|
||||
|
||||
def CartanMatrix(ct):
|
||||
"""Access the Cartan matrix of a specific Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_matrix import CartanMatrix
|
||||
>>> CartanMatrix("A2")
|
||||
Matrix([
|
||||
[ 2, -1],
|
||||
[-1, 2]])
|
||||
|
||||
>>> CartanMatrix(['C', 3])
|
||||
Matrix([
|
||||
[ 2, -1, 0],
|
||||
[-1, 2, -1],
|
||||
[ 0, -2, 2]])
|
||||
|
||||
This method works by returning the Cartan matrix
|
||||
which corresponds to Cartan type t.
|
||||
"""
|
||||
|
||||
return CartanType(ct).cartan_matrix()
|
||||
@@ -0,0 +1,73 @@
|
||||
from sympy.core import Atom, Basic
|
||||
|
||||
|
||||
class CartanType_generator():
|
||||
"""
|
||||
Constructor for actually creating things
|
||||
"""
|
||||
def __call__(self, *args):
|
||||
c = args[0]
|
||||
if isinstance(c, list):
|
||||
letter, n = c[0], int(c[1])
|
||||
elif isinstance(c, str):
|
||||
letter, n = c[0], int(c[1:])
|
||||
else:
|
||||
raise TypeError("Argument must be a string (e.g. 'A3') or a list (e.g. ['A', 3])")
|
||||
|
||||
if n < 0:
|
||||
raise ValueError("Lie algebra rank cannot be negative")
|
||||
if letter == "A":
|
||||
from . import type_a
|
||||
return type_a.TypeA(n)
|
||||
if letter == "B":
|
||||
from . import type_b
|
||||
return type_b.TypeB(n)
|
||||
|
||||
if letter == "C":
|
||||
from . import type_c
|
||||
return type_c.TypeC(n)
|
||||
|
||||
if letter == "D":
|
||||
from . import type_d
|
||||
return type_d.TypeD(n)
|
||||
|
||||
if letter == "E":
|
||||
if n >= 6 and n <= 8:
|
||||
from . import type_e
|
||||
return type_e.TypeE(n)
|
||||
|
||||
if letter == "F":
|
||||
if n == 4:
|
||||
from . import type_f
|
||||
return type_f.TypeF(n)
|
||||
|
||||
if letter == "G":
|
||||
if n == 2:
|
||||
from . import type_g
|
||||
return type_g.TypeG(n)
|
||||
|
||||
CartanType = CartanType_generator()
|
||||
|
||||
|
||||
class Standard_Cartan(Atom):
|
||||
"""
|
||||
Concrete base class for Cartan types such as A4, etc
|
||||
"""
|
||||
|
||||
def __new__(cls, series, n):
|
||||
obj = Basic.__new__(cls)
|
||||
obj.n = n
|
||||
obj.series = series
|
||||
return obj
|
||||
|
||||
def rank(self):
|
||||
"""
|
||||
Returns the rank of the Lie algebra
|
||||
"""
|
||||
return self.n
|
||||
|
||||
def series(self):
|
||||
"""
|
||||
Returns the type of the Lie algebra
|
||||
"""
|
||||
return self.series
|
||||
@@ -0,0 +1,24 @@
|
||||
from .cartan_type import CartanType
|
||||
|
||||
|
||||
def DynkinDiagram(t):
|
||||
"""Display the Dynkin diagram of a given Lie algebra
|
||||
|
||||
Works by generating the CartanType for the input, t, and then returning the
|
||||
Dynkin diagram method from the individual classes.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.dynkin_diagram import DynkinDiagram
|
||||
>>> print(DynkinDiagram("A3"))
|
||||
0---0---0
|
||||
1 2 3
|
||||
|
||||
>>> print(DynkinDiagram("B4"))
|
||||
0---0---0=>=0
|
||||
1 2 3 4
|
||||
|
||||
"""
|
||||
|
||||
return CartanType(t).dynkin_diagram()
|
||||
@@ -0,0 +1,196 @@
|
||||
from .cartan_type import CartanType
|
||||
from sympy.core.basic import Atom
|
||||
|
||||
class RootSystem(Atom):
|
||||
"""Represent the root system of a simple Lie algebra
|
||||
|
||||
Every simple Lie algebra has a unique root system. To find the root
|
||||
system, we first consider the Cartan subalgebra of g, which is the maximal
|
||||
abelian subalgebra, and consider the adjoint action of g on this
|
||||
subalgebra. There is a root system associated with this action. Now, a
|
||||
root system over a vector space V is a set of finite vectors Phi (called
|
||||
roots), which satisfy:
|
||||
|
||||
1. The roots span V
|
||||
2. The only scalar multiples of x in Phi are x and -x
|
||||
3. For every x in Phi, the set Phi is closed under reflection
|
||||
through the hyperplane perpendicular to x.
|
||||
4. If x and y are roots in Phi, then the projection of y onto
|
||||
the line through x is a half-integral multiple of x.
|
||||
|
||||
Now, there is a subset of Phi, which we will call Delta, such that:
|
||||
1. Delta is a basis of V
|
||||
2. Each root x in Phi can be written x = sum k_y y for y in Delta
|
||||
|
||||
The elements of Delta are called the simple roots.
|
||||
Therefore, we see that the simple roots span the root space of a given
|
||||
simple Lie algebra.
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
.. [1] https://en.wikipedia.org/wiki/Root_system
|
||||
.. [2] Lie Algebras and Representation Theory - Humphreys
|
||||
|
||||
"""
|
||||
|
||||
def __new__(cls, cartantype):
|
||||
"""Create a new RootSystem object
|
||||
|
||||
This method assigns an attribute called cartan_type to each instance of
|
||||
a RootSystem object. When an instance of RootSystem is called, it
|
||||
needs an argument, which should be an instance of a simple Lie algebra.
|
||||
We then take the CartanType of this argument and set it as the
|
||||
cartan_type attribute of the RootSystem instance.
|
||||
|
||||
"""
|
||||
obj = Atom.__new__(cls)
|
||||
obj.cartan_type = CartanType(cartantype)
|
||||
return obj
|
||||
|
||||
def simple_roots(self):
|
||||
"""Generate the simple roots of the Lie algebra
|
||||
|
||||
The rank of the Lie algebra determines the number of simple roots that
|
||||
it has. This method obtains the rank of the Lie algebra, and then uses
|
||||
the simple_root method from the Lie algebra classes to generate all the
|
||||
simple roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.root_system import RootSystem
|
||||
>>> c = RootSystem("A3")
|
||||
>>> roots = c.simple_roots()
|
||||
>>> roots
|
||||
{1: [1, -1, 0, 0], 2: [0, 1, -1, 0], 3: [0, 0, 1, -1]}
|
||||
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
roots = {i: self.cartan_type.simple_root(i) for i in range(1, n+1)}
|
||||
return roots
|
||||
|
||||
|
||||
def all_roots(self):
|
||||
"""Generate all the roots of a given root system
|
||||
|
||||
The result is a dictionary where the keys are integer numbers. It
|
||||
generates the roots by getting the dictionary of all positive roots
|
||||
from the bases classes, and then taking each root, and multiplying it
|
||||
by -1 and adding it to the dictionary. In this way all the negative
|
||||
roots are generated.
|
||||
|
||||
"""
|
||||
alpha = self.cartan_type.positive_roots()
|
||||
keys = list(alpha.keys())
|
||||
k = max(keys)
|
||||
for val in keys:
|
||||
k += 1
|
||||
root = alpha[val]
|
||||
newroot = [-x for x in root]
|
||||
alpha[k] = newroot
|
||||
return alpha
|
||||
|
||||
def root_space(self):
|
||||
"""Return the span of the simple roots
|
||||
|
||||
The root space is the vector space spanned by the simple roots, i.e. it
|
||||
is a vector space with a distinguished basis, the simple roots. This
|
||||
method returns a string that represents the root space as the span of
|
||||
the simple roots, alpha[1],...., alpha[n].
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.root_system import RootSystem
|
||||
>>> c = RootSystem("A3")
|
||||
>>> c.root_space()
|
||||
'alpha[1] + alpha[2] + alpha[3]'
|
||||
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
rs = " + ".join("alpha["+str(i) +"]" for i in range(1, n+1))
|
||||
return rs
|
||||
|
||||
def add_simple_roots(self, root1, root2):
|
||||
"""Add two simple roots together
|
||||
|
||||
The function takes as input two integers, root1 and root2. It then
|
||||
uses these integers as keys in the dictionary of simple roots, and gets
|
||||
the corresponding simple roots, and then adds them together.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.root_system import RootSystem
|
||||
>>> c = RootSystem("A3")
|
||||
>>> newroot = c.add_simple_roots(1, 2)
|
||||
>>> newroot
|
||||
[1, 0, -1, 0]
|
||||
|
||||
"""
|
||||
|
||||
alpha = self.simple_roots()
|
||||
if root1 > len(alpha) or root2 > len(alpha):
|
||||
raise ValueError("You've used a root that doesn't exist!")
|
||||
a1 = alpha[root1]
|
||||
a2 = alpha[root2]
|
||||
newroot = [_a1 + _a2 for _a1, _a2 in zip(a1, a2)]
|
||||
return newroot
|
||||
|
||||
def add_as_roots(self, root1, root2):
|
||||
"""Add two roots together if and only if their sum is also a root
|
||||
|
||||
It takes as input two vectors which should be roots. It then computes
|
||||
their sum and checks if it is in the list of all possible roots. If it
|
||||
is, it returns the sum. Otherwise it returns a string saying that the
|
||||
sum is not a root.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.root_system import RootSystem
|
||||
>>> c = RootSystem("A3")
|
||||
>>> c.add_as_roots([1, 0, -1, 0], [0, 0, 1, -1])
|
||||
[1, 0, 0, -1]
|
||||
>>> c.add_as_roots([1, -1, 0, 0], [0, 0, -1, 1])
|
||||
'The sum of these two roots is not a root'
|
||||
|
||||
"""
|
||||
alpha = self.all_roots()
|
||||
newroot = [r1 + r2 for r1, r2 in zip(root1, root2)]
|
||||
if newroot in alpha.values():
|
||||
return newroot
|
||||
else:
|
||||
return "The sum of these two roots is not a root"
|
||||
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""Cartan matrix of Lie algebra associated with this root system
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.root_system import RootSystem
|
||||
>>> c = RootSystem("A3")
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0],
|
||||
[-1, 2, -1],
|
||||
[ 0, -1, 2]])
|
||||
"""
|
||||
return self.cartan_type.cartan_matrix()
|
||||
|
||||
def dynkin_diagram(self):
|
||||
"""Dynkin diagram of the Lie algebra associated with this root system
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.root_system import RootSystem
|
||||
>>> c = RootSystem("A3")
|
||||
>>> print(c.dynkin_diagram())
|
||||
0---0---0
|
||||
1 2 3
|
||||
"""
|
||||
return self.cartan_type.dynkin_diagram()
|
||||
@@ -0,0 +1,10 @@
|
||||
from sympy.liealgebras.cartan_matrix import CartanMatrix
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_CartanMatrix():
|
||||
c = CartanMatrix("A3")
|
||||
m = Matrix(3, 3, [2, -1, 0, -1, 2, -1, 0, -1, 2])
|
||||
assert c == m
|
||||
a = CartanMatrix(["G",2])
|
||||
mt = Matrix(2, 2, [2, -1, -3, 2])
|
||||
assert a == mt
|
||||
@@ -0,0 +1,12 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType, Standard_Cartan
|
||||
|
||||
def test_Standard_Cartan():
|
||||
c = CartanType("A4")
|
||||
assert c.rank() == 4
|
||||
assert c.series == "A"
|
||||
m = Standard_Cartan("A", 2)
|
||||
assert m.rank() == 2
|
||||
assert m.series == "A"
|
||||
b = CartanType("B12")
|
||||
assert b.rank() == 12
|
||||
assert b.series == "B"
|
||||
@@ -0,0 +1,9 @@
|
||||
from sympy.liealgebras.dynkin_diagram import DynkinDiagram
|
||||
|
||||
def test_DynkinDiagram():
|
||||
c = DynkinDiagram("A3")
|
||||
diag = "0---0---0\n1 2 3"
|
||||
assert c == diag
|
||||
ct = DynkinDiagram(["B", 3])
|
||||
diag2 = "0---0=>=0\n1 2 3"
|
||||
assert ct == diag2
|
||||
@@ -0,0 +1,18 @@
|
||||
from sympy.liealgebras.root_system import RootSystem
|
||||
from sympy.liealgebras.type_a import TypeA
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_root_system():
|
||||
c = RootSystem("A3")
|
||||
assert c.cartan_type == TypeA(3)
|
||||
assert c.simple_roots() == {1: [1, -1, 0, 0], 2: [0, 1, -1, 0], 3: [0, 0, 1, -1]}
|
||||
assert c.root_space() == "alpha[1] + alpha[2] + alpha[3]"
|
||||
assert c.cartan_matrix() == Matrix([[ 2, -1, 0], [-1, 2, -1], [ 0, -1, 2]])
|
||||
assert c.dynkin_diagram() == "0---0---0\n1 2 3"
|
||||
assert c.add_simple_roots(1, 2) == [1, 0, -1, 0]
|
||||
assert c.all_roots() == {1: [1, -1, 0, 0], 2: [1, 0, -1, 0],
|
||||
3: [1, 0, 0, -1], 4: [0, 1, -1, 0], 5: [0, 1, 0, -1],
|
||||
6: [0, 0, 1, -1], 7: [-1, 1, 0, 0], 8: [-1, 0, 1, 0],
|
||||
9: [-1, 0, 0, 1], 10: [0, -1, 1, 0],
|
||||
11: [0, -1, 0, 1], 12: [0, 0, -1, 1]}
|
||||
assert c.add_as_roots([1, 0, -1, 0], [0, 0, 1, -1]) == [1, 0, 0, -1]
|
||||
@@ -0,0 +1,17 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_type_A():
|
||||
c = CartanType("A3")
|
||||
m = Matrix(3, 3, [2, -1, 0, -1, 2, -1, 0, -1, 2])
|
||||
assert m == c.cartan_matrix()
|
||||
assert c.basis() == 8
|
||||
assert c.roots() == 12
|
||||
assert c.dimension() == 4
|
||||
assert c.simple_root(1) == [1, -1, 0, 0]
|
||||
assert c.highest_root() == [1, 0, 0, -1]
|
||||
assert c.lie_algebra() == "su(4)"
|
||||
diag = "0---0---0\n1 2 3"
|
||||
assert c.dynkin_diagram() == diag
|
||||
assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 0, -1, 0],
|
||||
3: [1, 0, 0, -1], 4: [0, 1, -1, 0], 5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
@@ -0,0 +1,17 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_type_B():
|
||||
c = CartanType("B3")
|
||||
m = Matrix(3, 3, [2, -1, 0, -1, 2, -2, 0, -1, 2])
|
||||
assert m == c.cartan_matrix()
|
||||
assert c.dimension() == 3
|
||||
assert c.roots() == 18
|
||||
assert c.simple_root(3) == [0, 0, 1]
|
||||
assert c.basis() == 3
|
||||
assert c.lie_algebra() == "so(6)"
|
||||
diag = "0---0=>=0\n1 2 3"
|
||||
assert c.dynkin_diagram() == diag
|
||||
assert c.positive_roots() == {1: [1, -1, 0], 2: [1, 1, 0], 3: [1, 0, -1],
|
||||
4: [1, 0, 1], 5: [0, 1, -1], 6: [0, 1, 1], 7: [1, 0, 0],
|
||||
8: [0, 1, 0], 9: [0, 0, 1]}
|
||||
@@ -0,0 +1,22 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_type_C():
|
||||
c = CartanType("C4")
|
||||
m = Matrix(4, 4, [2, -1, 0, 0, -1, 2, -1, 0, 0, -1, 2, -1, 0, 0, -2, 2])
|
||||
assert c.cartan_matrix() == m
|
||||
assert c.dimension() == 4
|
||||
assert c.simple_root(4) == [0, 0, 0, 2]
|
||||
assert c.roots() == 32
|
||||
assert c.basis() == 36
|
||||
assert c.lie_algebra() == "sp(8)"
|
||||
t = CartanType(['C', 3])
|
||||
assert t.dimension() == 3
|
||||
diag = "0---0---0=<=0\n1 2 3 4"
|
||||
assert c.dynkin_diagram() == diag
|
||||
assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 1, 0, 0],
|
||||
3: [1, 0, -1, 0], 4: [1, 0, 1, 0], 5: [1, 0, 0, -1],
|
||||
6: [1, 0, 0, 1], 7: [0, 1, -1, 0], 8: [0, 1, 1, 0],
|
||||
9: [0, 1, 0, -1], 10: [0, 1, 0, 1], 11: [0, 0, 1, -1],
|
||||
12: [0, 0, 1, 1], 13: [2, 0, 0, 0], 14: [0, 2, 0, 0], 15: [0, 0, 2, 0],
|
||||
16: [0, 0, 0, 2]}
|
||||
@@ -0,0 +1,19 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
|
||||
|
||||
def test_type_D():
|
||||
c = CartanType("D4")
|
||||
m = Matrix(4, 4, [2, -1, 0, 0, -1, 2, -1, -1, 0, -1, 2, 0, 0, -1, 0, 2])
|
||||
assert c.cartan_matrix() == m
|
||||
assert c.basis() == 6
|
||||
assert c.lie_algebra() == "so(8)"
|
||||
assert c.roots() == 24
|
||||
assert c.simple_root(3) == [0, 0, 1, -1]
|
||||
diag = " 3\n 0\n |\n |\n0---0---0\n1 2 4"
|
||||
assert diag == c.dynkin_diagram()
|
||||
assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 1, 0, 0],
|
||||
3: [1, 0, -1, 0], 4: [1, 0, 1, 0], 5: [1, 0, 0, -1], 6: [1, 0, 0, 1],
|
||||
7: [0, 1, -1, 0], 8: [0, 1, 1, 0], 9: [0, 1, 0, -1], 10: [0, 1, 0, 1],
|
||||
11: [0, 0, 1, -1], 12: [0, 0, 1, 1]}
|
||||
@@ -0,0 +1,22 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
from sympy.core.backend import Rational
|
||||
|
||||
def test_type_E():
|
||||
c = CartanType("E6")
|
||||
m = Matrix(6, 6, [2, 0, -1, 0, 0, 0, 0, 2, 0, -1, 0, 0,
|
||||
-1, 0, 2, -1, 0, 0, 0, -1, -1, 2, -1, 0, 0, 0, 0,
|
||||
-1, 2, -1, 0, 0, 0, 0, -1, 2])
|
||||
assert c.cartan_matrix() == m
|
||||
assert c.dimension() == 8
|
||||
assert c.simple_root(6) == [0, 0, 0, -1, 1, 0, 0, 0]
|
||||
assert c.roots() == 72
|
||||
assert c.basis() == 78
|
||||
diag = " "*8 + "2\n" + " "*8 + "0\n" + " "*8 + "|\n" + " "*8 + "|\n"
|
||||
diag += "---".join("0" for i in range(1, 6))+"\n"
|
||||
diag += "1 " + " ".join(str(i) for i in range(3, 7))
|
||||
assert c.dynkin_diagram() == diag
|
||||
posroots = c.positive_roots()
|
||||
assert posroots[8] == [1, 0, 0, 0, 1, 0, 0, 0]
|
||||
assert posroots[21] == [Rational(1,2),Rational(1,2),Rational(1,2),Rational(1,2),
|
||||
Rational(1,2),Rational(-1,2),Rational(-1,2),Rational(1,2)]
|
||||
@@ -0,0 +1,24 @@
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
from sympy.core.backend import S
|
||||
|
||||
def test_type_F():
|
||||
c = CartanType("F4")
|
||||
m = Matrix(4, 4, [2, -1, 0, 0, -1, 2, -2, 0, 0, -1, 2, -1, 0, 0, -1, 2])
|
||||
assert c.cartan_matrix() == m
|
||||
assert c.dimension() == 4
|
||||
assert c.simple_root(1) == [1, -1, 0, 0]
|
||||
assert c.simple_root(2) == [0, 1, -1, 0]
|
||||
assert c.simple_root(3) == [0, 0, 0, 1]
|
||||
assert c.simple_root(4) == [-S.Half, -S.Half, -S.Half, -S.Half]
|
||||
assert c.roots() == 48
|
||||
assert c.basis() == 52
|
||||
diag = "0---0=>=0---0\n" + " ".join(str(i) for i in range(1, 5))
|
||||
assert c.dynkin_diagram() == diag
|
||||
assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 1, 0, 0], 3: [1, 0, -1, 0],
|
||||
4: [1, 0, 1, 0], 5: [1, 0, 0, -1], 6: [1, 0, 0, 1], 7: [0, 1, -1, 0],
|
||||
8: [0, 1, 1, 0], 9: [0, 1, 0, -1], 10: [0, 1, 0, 1], 11: [0, 0, 1, -1],
|
||||
12: [0, 0, 1, 1], 13: [1, 0, 0, 0], 14: [0, 1, 0, 0], 15: [0, 0, 1, 0],
|
||||
16: [0, 0, 0, 1], 17: [S.Half, S.Half, S.Half, S.Half], 18: [S.Half, -S.Half, S.Half, S.Half],
|
||||
19: [S.Half, S.Half, -S.Half, S.Half], 20: [S.Half, S.Half, S.Half, -S.Half], 21: [S.Half, S.Half, -S.Half, -S.Half],
|
||||
22: [S.Half, -S.Half, S.Half, -S.Half], 23: [S.Half, -S.Half, -S.Half, S.Half], 24: [S.Half, -S.Half, -S.Half, -S.Half]}
|
||||
@@ -0,0 +1,16 @@
|
||||
# coding=utf-8
|
||||
from sympy.liealgebras.cartan_type import CartanType
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_type_G():
|
||||
c = CartanType("G2")
|
||||
m = Matrix(2, 2, [2, -1, -3, 2])
|
||||
assert c.cartan_matrix() == m
|
||||
assert c.simple_root(2) == [1, -2, 1]
|
||||
assert c.basis() == 14
|
||||
assert c.roots() == 12
|
||||
assert c.dimension() == 3
|
||||
diag = "0≡<≡0\n1 2"
|
||||
assert diag == c.dynkin_diagram()
|
||||
assert c.positive_roots() == {1: [0, 1, -1], 2: [1, -2, 1], 3: [1, -1, 0],
|
||||
4: [1, 0, 1], 5: [1, 1, -2], 6: [2, -1, -1]}
|
||||
@@ -0,0 +1,35 @@
|
||||
from sympy.liealgebras.weyl_group import WeylGroup
|
||||
from sympy.matrices import Matrix
|
||||
|
||||
def test_weyl_group():
|
||||
c = WeylGroup("A3")
|
||||
assert c.matrix_form('r1*r2') == Matrix([[0, 0, 1, 0], [1, 0, 0, 0],
|
||||
[0, 1, 0, 0], [0, 0, 0, 1]])
|
||||
assert c.generators() == ['r1', 'r2', 'r3']
|
||||
assert c.group_order() == 24.0
|
||||
assert c.group_name() == "S4: the symmetric group acting on 4 elements."
|
||||
assert c.coxeter_diagram() == "0---0---0\n1 2 3"
|
||||
assert c.element_order('r1*r2*r3') == 4
|
||||
assert c.element_order('r1*r3*r2*r3') == 3
|
||||
d = WeylGroup("B5")
|
||||
assert d.group_order() == 3840
|
||||
assert d.element_order('r1*r2*r4*r5') == 12
|
||||
assert d.matrix_form('r2*r3') == Matrix([[0, 0, 1, 0, 0], [1, 0, 0, 0, 0],
|
||||
[0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]])
|
||||
assert d.element_order('r1*r2*r1*r3*r5') == 6
|
||||
e = WeylGroup("D5")
|
||||
assert e.element_order('r2*r3*r5') == 4
|
||||
assert e.matrix_form('r2*r3*r5') == Matrix([[1, 0, 0, 0, 0], [0, 0, 0, 0, -1],
|
||||
[0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, -1, 0]])
|
||||
f = WeylGroup("G2")
|
||||
assert f.element_order('r1*r2*r1*r2') == 3
|
||||
assert f.element_order('r2*r1*r1*r2') == 1
|
||||
|
||||
assert f.matrix_form('r1*r2*r1*r2') == Matrix([[0, 1, 0], [0, 0, 1], [1, 0, 0]])
|
||||
g = WeylGroup("F4")
|
||||
assert g.matrix_form('r2*r3') == Matrix([[1, 0, 0, 0], [0, 1, 0, 0],
|
||||
[0, 0, 0, -1], [0, 0, 1, 0]])
|
||||
|
||||
assert g.element_order('r2*r3') == 4
|
||||
h = WeylGroup("E6")
|
||||
assert h.group_order() == 51840
|
||||
@@ -0,0 +1,164 @@
|
||||
from sympy.liealgebras.cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import eye
|
||||
|
||||
|
||||
class TypeA(Standard_Cartan):
|
||||
"""
|
||||
This class contains the information about
|
||||
the A series of simple Lie algebras.
|
||||
====
|
||||
"""
|
||||
|
||||
def __new__(cls, n):
|
||||
if n < 1:
|
||||
raise ValueError("n cannot be less than 1")
|
||||
return Standard_Cartan.__new__(cls, "A", n)
|
||||
|
||||
|
||||
def dimension(self):
|
||||
"""Dimension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A4")
|
||||
>>> c.dimension()
|
||||
5
|
||||
"""
|
||||
return self.n+1
|
||||
|
||||
|
||||
def basic_root(self, i, j):
|
||||
"""
|
||||
This is a method just to generate roots
|
||||
with a 1 iin the ith position and a -1
|
||||
in the jth position.
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
root = [0]*(n+1)
|
||||
root[i] = 1
|
||||
root[j] = -1
|
||||
return root
|
||||
|
||||
def simple_root(self, i):
|
||||
"""
|
||||
Every lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
In A_n the ith simple root is the root which has a 1
|
||||
in the ith position, a -1 in the (i+1)th position,
|
||||
and zeroes elsewhere.
|
||||
|
||||
This method returns the ith simple root for the A series.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A4")
|
||||
>>> c.simple_root(1)
|
||||
[1, -1, 0, 0, 0]
|
||||
|
||||
"""
|
||||
|
||||
return self.basic_root(i-1, i)
|
||||
|
||||
def positive_roots(self):
|
||||
"""
|
||||
This method generates all the positive roots of
|
||||
A_n. This is half of all of the roots of A_n;
|
||||
by multiplying all the positive roots by -1 we
|
||||
get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(0, n):
|
||||
for j in range(i+1, n+1):
|
||||
k += 1
|
||||
posroots[k] = self.basic_root(i, j)
|
||||
return posroots
|
||||
|
||||
def highest_root(self):
|
||||
"""
|
||||
Returns the highest weight root for A_n
|
||||
"""
|
||||
|
||||
return self.basic_root(0, self.n)
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots for A_n
|
||||
"""
|
||||
n = self.n
|
||||
return n*(n+1)
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""
|
||||
Returns the Cartan matrix for A_n.
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType('A4')
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0, 0],
|
||||
[-1, 2, -1, 0],
|
||||
[ 0, -1, 2, -1],
|
||||
[ 0, 0, -1, 2]])
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
m = 2 * eye(n)
|
||||
for i in range(1, n - 1):
|
||||
m[i, i+1] = -1
|
||||
m[i, i-1] = -1
|
||||
m[0,1] = -1
|
||||
m[n-1, n-2] = -1
|
||||
return m
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of A_n
|
||||
"""
|
||||
n = self.n
|
||||
return n**2 - 1
|
||||
|
||||
def lie_algebra(self):
|
||||
"""
|
||||
Returns the Lie algebra associated with A_n
|
||||
"""
|
||||
n = self.n
|
||||
return "su(" + str(n + 1) + ")"
|
||||
|
||||
def dynkin_diagram(self):
|
||||
n = self.n
|
||||
diag = "---".join("0" for i in range(1, n+1)) + "\n"
|
||||
diag += " ".join(str(i) for i in range(1, n+1))
|
||||
return diag
|
||||
@@ -0,0 +1,170 @@
|
||||
from .cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import eye
|
||||
|
||||
class TypeB(Standard_Cartan):
|
||||
|
||||
def __new__(cls, n):
|
||||
if n < 2:
|
||||
raise ValueError("n cannot be less than 2")
|
||||
return Standard_Cartan.__new__(cls, "B", n)
|
||||
|
||||
def dimension(self):
|
||||
"""Dimension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("B3")
|
||||
>>> c.dimension()
|
||||
3
|
||||
"""
|
||||
|
||||
return self.n
|
||||
|
||||
def basic_root(self, i, j):
|
||||
"""
|
||||
This is a method just to generate roots
|
||||
with a 1 iin the ith position and a -1
|
||||
in the jth position.
|
||||
|
||||
"""
|
||||
root = [0]*self.n
|
||||
root[i] = 1
|
||||
root[j] = -1
|
||||
return root
|
||||
|
||||
def simple_root(self, i):
|
||||
"""
|
||||
Every lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
In B_n the first n-1 simple roots are the same as the
|
||||
roots in A_(n-1) (a 1 in the ith position, a -1 in
|
||||
the (i+1)th position, and zeroes elsewhere). The n-th
|
||||
simple root is the root with a 1 in the nth position
|
||||
and zeroes elsewhere.
|
||||
|
||||
This method returns the ith simple root for the B series.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("B3")
|
||||
>>> c.simple_root(2)
|
||||
[0, 1, -1]
|
||||
|
||||
"""
|
||||
n = self.n
|
||||
if i < n:
|
||||
return self.basic_root(i-1, i)
|
||||
else:
|
||||
root = [0]*self.n
|
||||
root[n-1] = 1
|
||||
return root
|
||||
|
||||
def positive_roots(self):
|
||||
"""
|
||||
This method generates all the positive roots of
|
||||
A_n. This is half of all of the roots of B_n;
|
||||
by multiplying all the positive roots by -1 we
|
||||
get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(0, n-1):
|
||||
for j in range(i+1, n):
|
||||
k += 1
|
||||
posroots[k] = self.basic_root(i, j)
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[j] = 1
|
||||
posroots[k] = root
|
||||
|
||||
for i in range(0, n):
|
||||
k += 1
|
||||
root = [0]*n
|
||||
root[i] = 1
|
||||
posroots[k] = root
|
||||
|
||||
return posroots
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots for B_n"
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return 2*(n**2)
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""
|
||||
Returns the Cartan matrix for B_n.
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType('B4')
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0, 0],
|
||||
[-1, 2, -1, 0],
|
||||
[ 0, -1, 2, -2],
|
||||
[ 0, 0, -1, 2]])
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
m = 2* eye(n)
|
||||
for i in range(1, n - 1):
|
||||
m[i, i+1] = -1
|
||||
m[i, i-1] = -1
|
||||
m[0, 1] = -1
|
||||
m[n-2, n-1] = -2
|
||||
m[n-1, n-2] = -1
|
||||
return m
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of B_n
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return (n**2 - n)/2
|
||||
|
||||
def lie_algebra(self):
|
||||
"""
|
||||
Returns the Lie algebra associated with B_n
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return "so(" + str(2*n) + ")"
|
||||
|
||||
def dynkin_diagram(self):
|
||||
n = self.n
|
||||
diag = "---".join("0" for i in range(1, n)) + "=>=0\n"
|
||||
diag += " ".join(str(i) for i in range(1, n+1))
|
||||
return diag
|
||||
@@ -0,0 +1,169 @@
|
||||
from .cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import eye
|
||||
|
||||
class TypeC(Standard_Cartan):
|
||||
|
||||
def __new__(cls, n):
|
||||
if n < 3:
|
||||
raise ValueError("n cannot be less than 3")
|
||||
return Standard_Cartan.__new__(cls, "C", n)
|
||||
|
||||
|
||||
def dimension(self):
|
||||
"""Dimension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("C3")
|
||||
>>> c.dimension()
|
||||
3
|
||||
"""
|
||||
n = self.n
|
||||
return n
|
||||
|
||||
def basic_root(self, i, j):
|
||||
"""Generate roots with 1 in ith position and a -1 in jth position
|
||||
"""
|
||||
n = self.n
|
||||
root = [0]*n
|
||||
root[i] = 1
|
||||
root[j] = -1
|
||||
return root
|
||||
|
||||
def simple_root(self, i):
|
||||
"""The ith simple root for the C series
|
||||
|
||||
Every lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
In C_n, the first n-1 simple roots are the same as
|
||||
the roots in A_(n-1) (a 1 in the ith position, a -1
|
||||
in the (i+1)th position, and zeroes elsewhere). The
|
||||
nth simple root is the root in which there is a 2 in
|
||||
the nth position and zeroes elsewhere.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("C3")
|
||||
>>> c.simple_root(2)
|
||||
[0, 1, -1]
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
if i < n:
|
||||
return self.basic_root(i-1,i)
|
||||
else:
|
||||
root = [0]*self.n
|
||||
root[n-1] = 2
|
||||
return root
|
||||
|
||||
|
||||
def positive_roots(self):
|
||||
"""Generates all the positive roots of A_n
|
||||
|
||||
This is half of all of the roots of C_n; by multiplying all the
|
||||
positive roots by -1 we get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(0, n-1):
|
||||
for j in range(i+1, n):
|
||||
k += 1
|
||||
posroots[k] = self.basic_root(i, j)
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[j] = 1
|
||||
posroots[k] = root
|
||||
|
||||
for i in range(0, n):
|
||||
k += 1
|
||||
root = [0]*n
|
||||
root[i] = 2
|
||||
posroots[k] = root
|
||||
|
||||
return posroots
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots for C_n"
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return 2*(n**2)
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""The Cartan matrix for C_n
|
||||
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType('C4')
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0, 0],
|
||||
[-1, 2, -1, 0],
|
||||
[ 0, -1, 2, -1],
|
||||
[ 0, 0, -2, 2]])
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
m = 2 * eye(n)
|
||||
for i in range(1, n - 1):
|
||||
m[i, i+1] = -1
|
||||
m[i, i-1] = -1
|
||||
m[0,1] = -1
|
||||
m[n-1, n-2] = -2
|
||||
return m
|
||||
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of C_n
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return n*(2*n + 1)
|
||||
|
||||
def lie_algebra(self):
|
||||
"""
|
||||
Returns the Lie algebra associated with C_n"
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return "sp(" + str(2*n) + ")"
|
||||
|
||||
def dynkin_diagram(self):
|
||||
n = self.n
|
||||
diag = "---".join("0" for i in range(1, n)) + "=<=0\n"
|
||||
diag += " ".join(str(i) for i in range(1, n+1))
|
||||
return diag
|
||||
@@ -0,0 +1,173 @@
|
||||
from .cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import eye
|
||||
|
||||
class TypeD(Standard_Cartan):
|
||||
|
||||
def __new__(cls, n):
|
||||
if n < 3:
|
||||
raise ValueError("n cannot be less than 3")
|
||||
return Standard_Cartan.__new__(cls, "D", n)
|
||||
|
||||
|
||||
def dimension(self):
|
||||
"""Dmension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("D4")
|
||||
>>> c.dimension()
|
||||
4
|
||||
"""
|
||||
|
||||
return self.n
|
||||
|
||||
def basic_root(self, i, j):
|
||||
"""
|
||||
This is a method just to generate roots
|
||||
with a 1 iin the ith position and a -1
|
||||
in the jth position.
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
root = [0]*n
|
||||
root[i] = 1
|
||||
root[j] = -1
|
||||
return root
|
||||
|
||||
def simple_root(self, i):
|
||||
"""
|
||||
Every lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
In D_n, the first n-1 simple roots are the same as
|
||||
the roots in A_(n-1) (a 1 in the ith position, a -1
|
||||
in the (i+1)th position, and zeroes elsewhere).
|
||||
The nth simple root is the root in which there 1s in
|
||||
the nth and (n-1)th positions, and zeroes elsewhere.
|
||||
|
||||
This method returns the ith simple root for the D series.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("D4")
|
||||
>>> c.simple_root(2)
|
||||
[0, 1, -1, 0]
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
if i < n:
|
||||
return self.basic_root(i-1, i)
|
||||
else:
|
||||
root = [0]*n
|
||||
root[n-2] = 1
|
||||
root[n-1] = 1
|
||||
return root
|
||||
|
||||
|
||||
def positive_roots(self):
|
||||
"""
|
||||
This method generates all the positive roots of
|
||||
A_n. This is half of all of the roots of D_n
|
||||
by multiplying all the positive roots by -1 we
|
||||
get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(0, n-1):
|
||||
for j in range(i+1, n):
|
||||
k += 1
|
||||
posroots[k] = self.basic_root(i, j)
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[j] = 1
|
||||
posroots[k] = root
|
||||
return posroots
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots for D_n"
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return 2*n*(n-1)
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""
|
||||
Returns the Cartan matrix for D_n.
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType('D4')
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0, 0],
|
||||
[-1, 2, -1, -1],
|
||||
[ 0, -1, 2, 0],
|
||||
[ 0, -1, 0, 2]])
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
m = 2*eye(n)
|
||||
for i in range(1, n - 2):
|
||||
m[i,i+1] = -1
|
||||
m[i,i-1] = -1
|
||||
m[n-2, n-3] = -1
|
||||
m[n-3, n-1] = -1
|
||||
m[n-1, n-3] = -1
|
||||
m[0, 1] = -1
|
||||
return m
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of D_n
|
||||
"""
|
||||
n = self.n
|
||||
return n*(n-1)/2
|
||||
|
||||
def lie_algebra(self):
|
||||
"""
|
||||
Returns the Lie algebra associated with D_n"
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
return "so(" + str(2*n) + ")"
|
||||
|
||||
def dynkin_diagram(self):
|
||||
n = self.n
|
||||
diag = " "*4*(n-3) + str(n-1) + "\n"
|
||||
diag += " "*4*(n-3) + "0\n"
|
||||
diag += " "*4*(n-3) +"|\n"
|
||||
diag += " "*4*(n-3) + "|\n"
|
||||
diag += "---".join("0" for i in range(1,n)) + "\n"
|
||||
diag += " ".join(str(i) for i in range(1, n-1)) + " "+str(n)
|
||||
return diag
|
||||
@@ -0,0 +1,275 @@
|
||||
import itertools
|
||||
|
||||
from .cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import eye, Rational
|
||||
from sympy.core.singleton import S
|
||||
|
||||
class TypeE(Standard_Cartan):
|
||||
|
||||
def __new__(cls, n):
|
||||
if n < 6 or n > 8:
|
||||
raise ValueError("Invalid value of n")
|
||||
return Standard_Cartan.__new__(cls, "E", n)
|
||||
|
||||
def dimension(self):
|
||||
"""Dimension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("E6")
|
||||
>>> c.dimension()
|
||||
8
|
||||
"""
|
||||
|
||||
return 8
|
||||
|
||||
def basic_root(self, i, j):
|
||||
"""
|
||||
This is a method just to generate roots
|
||||
with a -1 in the ith position and a 1
|
||||
in the jth position.
|
||||
|
||||
"""
|
||||
|
||||
root = [0]*8
|
||||
root[i] = -1
|
||||
root[j] = 1
|
||||
return root
|
||||
|
||||
def simple_root(self, i):
|
||||
"""
|
||||
Every Lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
This method returns the ith simple root for E_n.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("E6")
|
||||
>>> c.simple_root(2)
|
||||
[1, 1, 0, 0, 0, 0, 0, 0]
|
||||
"""
|
||||
n = self.n
|
||||
if i == 1:
|
||||
root = [-0.5]*8
|
||||
root[0] = 0.5
|
||||
root[7] = 0.5
|
||||
return root
|
||||
elif i == 2:
|
||||
root = [0]*8
|
||||
root[1] = 1
|
||||
root[0] = 1
|
||||
return root
|
||||
else:
|
||||
if i in (7, 8) and n == 6:
|
||||
raise ValueError("E6 only has six simple roots!")
|
||||
if i == 8 and n == 7:
|
||||
raise ValueError("E7 only has seven simple roots!")
|
||||
|
||||
return self.basic_root(i - 3, i - 2)
|
||||
|
||||
def positive_roots(self):
|
||||
"""
|
||||
This method generates all the positive roots of
|
||||
A_n. This is half of all of the roots of E_n;
|
||||
by multiplying all the positive roots by -1 we
|
||||
get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
"""
|
||||
n = self.n
|
||||
neghalf = Rational(-1, 2)
|
||||
poshalf = S.Half
|
||||
if n == 6:
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(n-1):
|
||||
for j in range(i+1, n-1):
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
posroots[k] = root
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[i] = 1
|
||||
posroots[k] = root
|
||||
|
||||
root = [poshalf, poshalf, poshalf, poshalf, poshalf,
|
||||
neghalf, neghalf, poshalf]
|
||||
for a, b, c, d, e in itertools.product(
|
||||
range(2), range(2), range(2), range(2), range(2)):
|
||||
if (a + b + c + d + e)%2 == 0:
|
||||
k += 1
|
||||
if a == 1:
|
||||
root[0] = neghalf
|
||||
if b == 1:
|
||||
root[1] = neghalf
|
||||
if c == 1:
|
||||
root[2] = neghalf
|
||||
if d == 1:
|
||||
root[3] = neghalf
|
||||
if e == 1:
|
||||
root[4] = neghalf
|
||||
posroots[k] = root[:]
|
||||
return posroots
|
||||
if n == 7:
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(n-1):
|
||||
for j in range(i+1, n-1):
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
posroots[k] = root
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[i] = 1
|
||||
posroots[k] = root
|
||||
|
||||
k += 1
|
||||
posroots[k] = [0, 0, 0, 0, 0, 1, 1, 0]
|
||||
root = [poshalf, poshalf, poshalf, poshalf, poshalf,
|
||||
neghalf, neghalf, poshalf]
|
||||
for a, b, c, d, e, f in itertools.product(
|
||||
range(2), range(2), range(2), range(2), range(2), range(2)):
|
||||
if (a + b + c + d + e + f)%2 == 0:
|
||||
k += 1
|
||||
if a == 1:
|
||||
root[0] = neghalf
|
||||
if b == 1:
|
||||
root[1] = neghalf
|
||||
if c == 1:
|
||||
root[2] = neghalf
|
||||
if d == 1:
|
||||
root[3] = neghalf
|
||||
if e == 1:
|
||||
root[4] = neghalf
|
||||
if f == 1:
|
||||
root[5] = poshalf
|
||||
posroots[k] = root[:]
|
||||
return posroots
|
||||
if n == 8:
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(n):
|
||||
for j in range(i+1, n):
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
posroots[k] = root
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[i] = 1
|
||||
posroots[k] = root
|
||||
|
||||
root = [poshalf, poshalf, poshalf, poshalf, poshalf,
|
||||
neghalf, neghalf, poshalf]
|
||||
for a, b, c, d, e, f, g in itertools.product(
|
||||
range(2), range(2), range(2), range(2), range(2),
|
||||
range(2), range(2)):
|
||||
if (a + b + c + d + e + f + g)%2 == 0:
|
||||
k += 1
|
||||
if a == 1:
|
||||
root[0] = neghalf
|
||||
if b == 1:
|
||||
root[1] = neghalf
|
||||
if c == 1:
|
||||
root[2] = neghalf
|
||||
if d == 1:
|
||||
root[3] = neghalf
|
||||
if e == 1:
|
||||
root[4] = neghalf
|
||||
if f == 1:
|
||||
root[5] = poshalf
|
||||
if g == 1:
|
||||
root[6] = poshalf
|
||||
posroots[k] = root[:]
|
||||
return posroots
|
||||
|
||||
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots of E_n
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
if n == 6:
|
||||
return 72
|
||||
if n == 7:
|
||||
return 126
|
||||
if n == 8:
|
||||
return 240
|
||||
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""
|
||||
Returns the Cartan matrix for G_2
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType('A4')
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0, 0],
|
||||
[-1, 2, -1, 0],
|
||||
[ 0, -1, 2, -1],
|
||||
[ 0, 0, -1, 2]])
|
||||
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
m = 2*eye(n)
|
||||
for i in range(3, n - 1):
|
||||
m[i, i+1] = -1
|
||||
m[i, i-1] = -1
|
||||
m[0, 2] = m[2, 0] = -1
|
||||
m[1, 3] = m[3, 1] = -1
|
||||
m[2, 3] = -1
|
||||
m[n-1, n-2] = -1
|
||||
return m
|
||||
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of E_n
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
if n == 6:
|
||||
return 78
|
||||
if n == 7:
|
||||
return 133
|
||||
if n == 8:
|
||||
return 248
|
||||
|
||||
def dynkin_diagram(self):
|
||||
n = self.n
|
||||
diag = " "*8 + str(2) + "\n"
|
||||
diag += " "*8 + "0\n"
|
||||
diag += " "*8 + "|\n"
|
||||
diag += " "*8 + "|\n"
|
||||
diag += "---".join("0" for i in range(1, n)) + "\n"
|
||||
diag += "1 " + " ".join(str(i) for i in range(3, n+1))
|
||||
return diag
|
||||
@@ -0,0 +1,162 @@
|
||||
from .cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import Matrix, Rational
|
||||
|
||||
|
||||
class TypeF(Standard_Cartan):
|
||||
|
||||
def __new__(cls, n):
|
||||
if n != 4:
|
||||
raise ValueError("n should be 4")
|
||||
return Standard_Cartan.__new__(cls, "F", 4)
|
||||
|
||||
def dimension(self):
|
||||
"""Dimension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("F4")
|
||||
>>> c.dimension()
|
||||
4
|
||||
"""
|
||||
|
||||
return 4
|
||||
|
||||
|
||||
def basic_root(self, i, j):
|
||||
"""Generate roots with 1 in ith position and -1 in jth position
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
root = [0]*n
|
||||
root[i] = 1
|
||||
root[j] = -1
|
||||
return root
|
||||
|
||||
def simple_root(self, i):
|
||||
"""The ith simple root of F_4
|
||||
|
||||
Every lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("F4")
|
||||
>>> c.simple_root(3)
|
||||
[0, 0, 0, 1]
|
||||
|
||||
"""
|
||||
|
||||
if i < 3:
|
||||
return self.basic_root(i-1, i)
|
||||
if i == 3:
|
||||
root = [0]*4
|
||||
root[3] = 1
|
||||
return root
|
||||
if i == 4:
|
||||
root = [Rational(-1, 2)]*4
|
||||
return root
|
||||
|
||||
def positive_roots(self):
|
||||
"""Generate all the positive roots of A_n
|
||||
|
||||
This is half of all of the roots of F_4; by multiplying all the
|
||||
positive roots by -1 we get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
|
||||
"""
|
||||
|
||||
n = self.n
|
||||
posroots = {}
|
||||
k = 0
|
||||
for i in range(0, n-1):
|
||||
for j in range(i+1, n):
|
||||
k += 1
|
||||
posroots[k] = self.basic_root(i, j)
|
||||
k += 1
|
||||
root = self.basic_root(i, j)
|
||||
root[j] = 1
|
||||
posroots[k] = root
|
||||
|
||||
for i in range(0, n):
|
||||
k += 1
|
||||
root = [0]*n
|
||||
root[i] = 1
|
||||
posroots[k] = root
|
||||
|
||||
k += 1
|
||||
root = [Rational(1, 2)]*n
|
||||
posroots[k] = root
|
||||
for i in range(1, 4):
|
||||
k += 1
|
||||
root = [Rational(1, 2)]*n
|
||||
root[i] = Rational(-1, 2)
|
||||
posroots[k] = root
|
||||
|
||||
posroots[k+1] = [Rational(1, 2), Rational(1, 2), Rational(-1, 2), Rational(-1, 2)]
|
||||
posroots[k+2] = [Rational(1, 2), Rational(-1, 2), Rational(1, 2), Rational(-1, 2)]
|
||||
posroots[k+3] = [Rational(1, 2), Rational(-1, 2), Rational(-1, 2), Rational(1, 2)]
|
||||
posroots[k+4] = [Rational(1, 2), Rational(-1, 2), Rational(-1, 2), Rational(-1, 2)]
|
||||
|
||||
return posroots
|
||||
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots for F_4
|
||||
"""
|
||||
return 48
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""The Cartan matrix for F_4
|
||||
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType('A4')
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1, 0, 0],
|
||||
[-1, 2, -1, 0],
|
||||
[ 0, -1, 2, -1],
|
||||
[ 0, 0, -1, 2]])
|
||||
"""
|
||||
|
||||
m = Matrix( 4, 4, [2, -1, 0, 0, -1, 2, -2, 0, 0,
|
||||
-1, 2, -1, 0, 0, -1, 2])
|
||||
return m
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of F_4
|
||||
"""
|
||||
return 52
|
||||
|
||||
def dynkin_diagram(self):
|
||||
diag = "0---0=>=0---0\n"
|
||||
diag += " ".join(str(i) for i in range(1, 5))
|
||||
return diag
|
||||
@@ -0,0 +1,111 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .cartan_type import Standard_Cartan
|
||||
from sympy.core.backend import Matrix
|
||||
|
||||
class TypeG(Standard_Cartan):
|
||||
|
||||
def __new__(cls, n):
|
||||
if n != 2:
|
||||
raise ValueError("n should be 2")
|
||||
return Standard_Cartan.__new__(cls, "G", 2)
|
||||
|
||||
|
||||
def dimension(self):
|
||||
"""Dimension of the vector space V underlying the Lie algebra
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("G2")
|
||||
>>> c.dimension()
|
||||
3
|
||||
"""
|
||||
return 3
|
||||
|
||||
def simple_root(self, i):
|
||||
"""The ith simple root of G_2
|
||||
|
||||
Every lie algebra has a unique root system.
|
||||
Given a root system Q, there is a subset of the
|
||||
roots such that an element of Q is called a
|
||||
simple root if it cannot be written as the sum
|
||||
of two elements in Q. If we let D denote the
|
||||
set of simple roots, then it is clear that every
|
||||
element of Q can be written as a linear combination
|
||||
of elements of D with all coefficients non-negative.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("G2")
|
||||
>>> c.simple_root(1)
|
||||
[0, 1, -1]
|
||||
|
||||
"""
|
||||
if i == 1:
|
||||
return [0, 1, -1]
|
||||
else:
|
||||
return [1, -2, 1]
|
||||
|
||||
def positive_roots(self):
|
||||
"""Generate all the positive roots of A_n
|
||||
|
||||
This is half of all of the roots of A_n; by multiplying all the
|
||||
positive roots by -1 we get the negative roots.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("A3")
|
||||
>>> c.positive_roots()
|
||||
{1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 3: [1, 0, 0, -1], 4: [0, 1, -1, 0],
|
||||
5: [0, 1, 0, -1], 6: [0, 0, 1, -1]}
|
||||
|
||||
"""
|
||||
|
||||
roots = {1: [0, 1, -1], 2: [1, -2, 1], 3: [1, -1, 0], 4: [1, 0, 1],
|
||||
5: [1, 1, -2], 6: [2, -1, -1]}
|
||||
return roots
|
||||
|
||||
def roots(self):
|
||||
"""
|
||||
Returns the total number of roots of G_2"
|
||||
"""
|
||||
return 12
|
||||
|
||||
def cartan_matrix(self):
|
||||
"""The Cartan matrix for G_2
|
||||
|
||||
The Cartan matrix matrix for a Lie algebra is
|
||||
generated by assigning an ordering to the simple
|
||||
roots, (alpha[1], ...., alpha[l]). Then the ijth
|
||||
entry of the Cartan matrix is (<alpha[i],alpha[j]>).
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.cartan_type import CartanType
|
||||
>>> c = CartanType("G2")
|
||||
>>> c.cartan_matrix()
|
||||
Matrix([
|
||||
[ 2, -1],
|
||||
[-3, 2]])
|
||||
|
||||
"""
|
||||
|
||||
m = Matrix( 2, 2, [2, -1, -3, 2])
|
||||
return m
|
||||
|
||||
def basis(self):
|
||||
"""
|
||||
Returns the number of independent generators of G_2
|
||||
"""
|
||||
return 14
|
||||
|
||||
def dynkin_diagram(self):
|
||||
diag = "0≡<≡0\n1 2"
|
||||
return diag
|
||||
@@ -0,0 +1,403 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .cartan_type import CartanType
|
||||
from mpmath import fac
|
||||
from sympy.core.backend import Matrix, eye, Rational, igcd
|
||||
from sympy.core.basic import Atom
|
||||
|
||||
class WeylGroup(Atom):
|
||||
|
||||
"""
|
||||
For each semisimple Lie group, we have a Weyl group. It is a subgroup of
|
||||
the isometry group of the root system. Specifically, it's the subgroup
|
||||
that is generated by reflections through the hyperplanes orthogonal to
|
||||
the roots. Therefore, Weyl groups are reflection groups, and so a Weyl
|
||||
group is a finite Coxeter group.
|
||||
|
||||
"""
|
||||
|
||||
def __new__(cls, cartantype):
|
||||
obj = Atom.__new__(cls)
|
||||
obj.cartan_type = CartanType(cartantype)
|
||||
return obj
|
||||
|
||||
def generators(self):
|
||||
"""
|
||||
This method creates the generating reflections of the Weyl group for
|
||||
a given Lie algebra. For a Lie algebra of rank n, there are n
|
||||
different generating reflections. This function returns them as
|
||||
a list.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.weyl_group import WeylGroup
|
||||
>>> c = WeylGroup("F4")
|
||||
>>> c.generators()
|
||||
['r1', 'r2', 'r3', 'r4']
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
generators = []
|
||||
for i in range(1, n+1):
|
||||
reflection = "r"+str(i)
|
||||
generators.append(reflection)
|
||||
return generators
|
||||
|
||||
def group_order(self):
|
||||
"""
|
||||
This method returns the order of the Weyl group.
|
||||
For types A, B, C, D, and E the order depends on
|
||||
the rank of the Lie algebra. For types F and G,
|
||||
the order is fixed.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.weyl_group import WeylGroup
|
||||
>>> c = WeylGroup("D4")
|
||||
>>> c.group_order()
|
||||
192.0
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
if self.cartan_type.series == "A":
|
||||
return fac(n+1)
|
||||
|
||||
if self.cartan_type.series in ("B", "C"):
|
||||
return fac(n)*(2**n)
|
||||
|
||||
if self.cartan_type.series == "D":
|
||||
return fac(n)*(2**(n-1))
|
||||
|
||||
if self.cartan_type.series == "E":
|
||||
if n == 6:
|
||||
return 51840
|
||||
if n == 7:
|
||||
return 2903040
|
||||
if n == 8:
|
||||
return 696729600
|
||||
if self.cartan_type.series == "F":
|
||||
return 1152
|
||||
|
||||
if self.cartan_type.series == "G":
|
||||
return 12
|
||||
|
||||
def group_name(self):
|
||||
"""
|
||||
This method returns some general information about the Weyl group for
|
||||
a given Lie algebra. It returns the name of the group and the elements
|
||||
it acts on, if relevant.
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
if self.cartan_type.series == "A":
|
||||
return "S"+str(n+1) + ": the symmetric group acting on " + str(n+1) + " elements."
|
||||
|
||||
if self.cartan_type.series in ("B", "C"):
|
||||
return "The hyperoctahedral group acting on " + str(2*n) + " elements."
|
||||
|
||||
if self.cartan_type.series == "D":
|
||||
return "The symmetry group of the " + str(n) + "-dimensional demihypercube."
|
||||
|
||||
if self.cartan_type.series == "E":
|
||||
if n == 6:
|
||||
return "The symmetry group of the 6-polytope."
|
||||
|
||||
if n == 7:
|
||||
return "The symmetry group of the 7-polytope."
|
||||
|
||||
if n == 8:
|
||||
return "The symmetry group of the 8-polytope."
|
||||
|
||||
if self.cartan_type.series == "F":
|
||||
return "The symmetry group of the 24-cell, or icositetrachoron."
|
||||
|
||||
if self.cartan_type.series == "G":
|
||||
return "D6, the dihedral group of order 12, and symmetry group of the hexagon."
|
||||
|
||||
def element_order(self, weylelt):
|
||||
"""
|
||||
This method returns the order of a given Weyl group element, which should
|
||||
be specified by the user in the form of products of the generating
|
||||
reflections, i.e. of the form r1*r2 etc.
|
||||
|
||||
For types A-F, this method current works by taking the matrix form of
|
||||
the specified element, and then finding what power of the matrix is the
|
||||
identity. It then returns this power.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.weyl_group import WeylGroup
|
||||
>>> b = WeylGroup("B4")
|
||||
>>> b.element_order('r1*r4*r2')
|
||||
4
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
if self.cartan_type.series == "A":
|
||||
a = self.matrix_form(weylelt)
|
||||
order = 1
|
||||
while a != eye(n+1):
|
||||
a *= self.matrix_form(weylelt)
|
||||
order += 1
|
||||
return order
|
||||
|
||||
if self.cartan_type.series == "D":
|
||||
a = self.matrix_form(weylelt)
|
||||
order = 1
|
||||
while a != eye(n):
|
||||
a *= self.matrix_form(weylelt)
|
||||
order += 1
|
||||
return order
|
||||
|
||||
if self.cartan_type.series == "E":
|
||||
a = self.matrix_form(weylelt)
|
||||
order = 1
|
||||
while a != eye(8):
|
||||
a *= self.matrix_form(weylelt)
|
||||
order += 1
|
||||
return order
|
||||
|
||||
if self.cartan_type.series == "G":
|
||||
elts = list(weylelt)
|
||||
reflections = elts[1::3]
|
||||
m = self.delete_doubles(reflections)
|
||||
while self.delete_doubles(m) != m:
|
||||
m = self.delete_doubles(m)
|
||||
reflections = m
|
||||
if len(reflections) % 2 == 1:
|
||||
return 2
|
||||
|
||||
elif len(reflections) == 0:
|
||||
return 1
|
||||
|
||||
else:
|
||||
if len(reflections) == 1:
|
||||
return 2
|
||||
else:
|
||||
m = len(reflections) // 2
|
||||
lcm = (6 * m)/ igcd(m, 6)
|
||||
order = lcm / m
|
||||
return order
|
||||
|
||||
|
||||
if self.cartan_type.series == 'F':
|
||||
a = self.matrix_form(weylelt)
|
||||
order = 1
|
||||
while a != eye(4):
|
||||
a *= self.matrix_form(weylelt)
|
||||
order += 1
|
||||
return order
|
||||
|
||||
|
||||
if self.cartan_type.series in ("B", "C"):
|
||||
a = self.matrix_form(weylelt)
|
||||
order = 1
|
||||
while a != eye(n):
|
||||
a *= self.matrix_form(weylelt)
|
||||
order += 1
|
||||
return order
|
||||
|
||||
def delete_doubles(self, reflections):
|
||||
"""
|
||||
This is a helper method for determining the order of an element in the
|
||||
Weyl group of G2. It takes a Weyl element and if repeated simple reflections
|
||||
in it, it deletes them.
|
||||
"""
|
||||
counter = 0
|
||||
copy = list(reflections)
|
||||
for elt in copy:
|
||||
if counter < len(copy)-1:
|
||||
if copy[counter + 1] == elt:
|
||||
del copy[counter]
|
||||
del copy[counter]
|
||||
counter += 1
|
||||
|
||||
|
||||
return copy
|
||||
|
||||
|
||||
def matrix_form(self, weylelt):
|
||||
"""
|
||||
This method takes input from the user in the form of products of the
|
||||
generating reflections, and returns the matrix corresponding to the
|
||||
element of the Weyl group. Since each element of the Weyl group is
|
||||
a reflection of some type, there is a corresponding matrix representation.
|
||||
This method uses the standard representation for all the generating
|
||||
reflections.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.weyl_group import WeylGroup
|
||||
>>> f = WeylGroup("F4")
|
||||
>>> f.matrix_form('r2*r3')
|
||||
Matrix([
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 0, -1],
|
||||
[0, 0, 1, 0]])
|
||||
|
||||
"""
|
||||
elts = list(weylelt)
|
||||
reflections = elts[1::3]
|
||||
n = self.cartan_type.rank()
|
||||
if self.cartan_type.series == 'A':
|
||||
matrixform = eye(n+1)
|
||||
for elt in reflections:
|
||||
a = int(elt)
|
||||
mat = eye(n+1)
|
||||
mat[a-1, a-1] = 0
|
||||
mat[a-1, a] = 1
|
||||
mat[a, a-1] = 1
|
||||
mat[a, a] = 0
|
||||
matrixform *= mat
|
||||
return matrixform
|
||||
|
||||
if self.cartan_type.series == 'D':
|
||||
matrixform = eye(n)
|
||||
for elt in reflections:
|
||||
a = int(elt)
|
||||
mat = eye(n)
|
||||
if a < n:
|
||||
mat[a-1, a-1] = 0
|
||||
mat[a-1, a] = 1
|
||||
mat[a, a-1] = 1
|
||||
mat[a, a] = 0
|
||||
matrixform *= mat
|
||||
else:
|
||||
mat[n-2, n-1] = -1
|
||||
mat[n-2, n-2] = 0
|
||||
mat[n-1, n-2] = -1
|
||||
mat[n-1, n-1] = 0
|
||||
matrixform *= mat
|
||||
return matrixform
|
||||
|
||||
if self.cartan_type.series == 'G':
|
||||
matrixform = eye(3)
|
||||
for elt in reflections:
|
||||
a = int(elt)
|
||||
if a == 1:
|
||||
gen1 = Matrix([[1, 0, 0], [0, 0, 1], [0, 1, 0]])
|
||||
matrixform *= gen1
|
||||
else:
|
||||
gen2 = Matrix([[Rational(2, 3), Rational(2, 3), Rational(-1, 3)],
|
||||
[Rational(2, 3), Rational(-1, 3), Rational(2, 3)],
|
||||
[Rational(-1, 3), Rational(2, 3), Rational(2, 3)]])
|
||||
matrixform *= gen2
|
||||
return matrixform
|
||||
|
||||
if self.cartan_type.series == 'F':
|
||||
matrixform = eye(4)
|
||||
for elt in reflections:
|
||||
a = int(elt)
|
||||
if a == 1:
|
||||
mat = Matrix([[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]])
|
||||
matrixform *= mat
|
||||
elif a == 2:
|
||||
mat = Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])
|
||||
matrixform *= mat
|
||||
elif a == 3:
|
||||
mat = Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, -1]])
|
||||
matrixform *= mat
|
||||
else:
|
||||
|
||||
mat = Matrix([[Rational(1, 2), Rational(1, 2), Rational(1, 2), Rational(1, 2)],
|
||||
[Rational(1, 2), Rational(1, 2), Rational(-1, 2), Rational(-1, 2)],
|
||||
[Rational(1, 2), Rational(-1, 2), Rational(1, 2), Rational(-1, 2)],
|
||||
[Rational(1, 2), Rational(-1, 2), Rational(-1, 2), Rational(1, 2)]])
|
||||
matrixform *= mat
|
||||
return matrixform
|
||||
|
||||
if self.cartan_type.series == 'E':
|
||||
matrixform = eye(8)
|
||||
for elt in reflections:
|
||||
a = int(elt)
|
||||
if a == 1:
|
||||
mat = Matrix([[Rational(3, 4), Rational(1, 4), Rational(1, 4), Rational(1, 4),
|
||||
Rational(1, 4), Rational(1, 4), Rational(1, 4), Rational(-1, 4)],
|
||||
[Rational(1, 4), Rational(3, 4), Rational(-1, 4), Rational(-1, 4),
|
||||
Rational(-1, 4), Rational(-1, 4), Rational(1, 4), Rational(-1, 4)],
|
||||
[Rational(1, 4), Rational(-1, 4), Rational(3, 4), Rational(-1, 4),
|
||||
Rational(-1, 4), Rational(-1, 4), Rational(-1, 4), Rational(1, 4)],
|
||||
[Rational(1, 4), Rational(-1, 4), Rational(-1, 4), Rational(3, 4),
|
||||
Rational(-1, 4), Rational(-1, 4), Rational(-1, 4), Rational(1, 4)],
|
||||
[Rational(1, 4), Rational(-1, 4), Rational(-1, 4), Rational(-1, 4),
|
||||
Rational(3, 4), Rational(-1, 4), Rational(-1, 4), Rational(1, 4)],
|
||||
[Rational(1, 4), Rational(-1, 4), Rational(-1, 4), Rational(-1, 4),
|
||||
Rational(-1, 4), Rational(3, 4), Rational(-1, 4), Rational(1, 4)],
|
||||
[Rational(1, 4), Rational(-1, 4), Rational(-1, 4), Rational(-1, 4),
|
||||
Rational(-1, 4), Rational(-1, 4), Rational(-3, 4), Rational(1, 4)],
|
||||
[Rational(1, 4), Rational(-1, 4), Rational(-1, 4), Rational(-1, 4),
|
||||
Rational(-1, 4), Rational(-1, 4), Rational(-1, 4), Rational(3, 4)]])
|
||||
matrixform *= mat
|
||||
elif a == 2:
|
||||
mat = eye(8)
|
||||
mat[0, 0] = 0
|
||||
mat[0, 1] = -1
|
||||
mat[1, 0] = -1
|
||||
mat[1, 1] = 0
|
||||
matrixform *= mat
|
||||
else:
|
||||
mat = eye(8)
|
||||
mat[a-3, a-3] = 0
|
||||
mat[a-3, a-2] = 1
|
||||
mat[a-2, a-3] = 1
|
||||
mat[a-2, a-2] = 0
|
||||
matrixform *= mat
|
||||
return matrixform
|
||||
|
||||
|
||||
if self.cartan_type.series in ("B", "C"):
|
||||
matrixform = eye(n)
|
||||
for elt in reflections:
|
||||
a = int(elt)
|
||||
mat = eye(n)
|
||||
if a == 1:
|
||||
mat[0, 0] = -1
|
||||
matrixform *= mat
|
||||
else:
|
||||
mat[a - 2, a - 2] = 0
|
||||
mat[a-2, a-1] = 1
|
||||
mat[a - 1, a - 2] = 1
|
||||
mat[a -1, a - 1] = 0
|
||||
matrixform *= mat
|
||||
return matrixform
|
||||
|
||||
|
||||
|
||||
def coxeter_diagram(self):
|
||||
"""
|
||||
This method returns the Coxeter diagram corresponding to a Weyl group.
|
||||
The Coxeter diagram can be obtained from a Lie algebra's Dynkin diagram
|
||||
by deleting all arrows; the Coxeter diagram is the undirected graph.
|
||||
The vertices of the Coxeter diagram represent the generating reflections
|
||||
of the Weyl group, $s_i$. An edge is drawn between $s_i$ and $s_j$ if the order
|
||||
$m(i, j)$ of $s_is_j$ is greater than two. If there is one edge, the order
|
||||
$m(i, j)$ is 3. If there are two edges, the order $m(i, j)$ is 4, and if there
|
||||
are three edges, the order $m(i, j)$ is 6.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
>>> from sympy.liealgebras.weyl_group import WeylGroup
|
||||
>>> c = WeylGroup("B3")
|
||||
>>> print(c.coxeter_diagram())
|
||||
0---0===0
|
||||
1 2 3
|
||||
"""
|
||||
n = self.cartan_type.rank()
|
||||
if self.cartan_type.series in ("A", "D", "E"):
|
||||
return self.cartan_type.dynkin_diagram()
|
||||
|
||||
if self.cartan_type.series in ("B", "C"):
|
||||
diag = "---".join("0" for i in range(1, n)) + "===0\n"
|
||||
diag += " ".join(str(i) for i in range(1, n+1))
|
||||
return diag
|
||||
|
||||
if self.cartan_type.series == "F":
|
||||
diag = "0---0===0---0\n"
|
||||
diag += " ".join(str(i) for i in range(1, 5))
|
||||
return diag
|
||||
|
||||
if self.cartan_type.series == "G":
|
||||
diag = "0≡≡≡0\n1 2"
|
||||
return diag
|
||||
Reference in New Issue
Block a user