Skip to content

Commit 7e7b5ff

Browse files
committed
fix ReductiveLieAlgebra constructor
1 parent e35a2f3 commit 7e7b5ff

File tree

4 files changed

+76
-32
lines changed

4 files changed

+76
-32
lines changed

src/lie-groups/lie-algebras/algebras.jl

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,36 @@ struct ChevalleyBasis{T}
4141
negative_roots::Vector{Root}
4242
end
4343

44+
function ChevalleyBasis(
45+
std_basis::Vector{Matrix{T1}},
46+
cartan::Vector{Vector{T2}},
47+
positive::Vector{Vector{T3}},
48+
negative::Vector{Vector{T4}},
49+
positive_roots::Vector{Vector{Int}},
50+
negative_roots::Vector{Vector{Int}}
51+
) where {T1,T2,T3,T4}
52+
T = promote_type(T1, T2, T3, T4)
53+
return ChevalleyBasis{T}(std_basis, cartan, positive, negative, [Root(r) for r in positive_roots], [Root(r) for r in negative_roots])
54+
end
55+
56+
Base.convert(
57+
::Type{ChevalleyBasis{T}},
58+
ch_basis::ChevalleyBasis
59+
) where {T} = ChevalleyBasis(
60+
convert(Vector{Matrix{T}}, ch_basis.std_basis),
61+
convert(Vector{Vector{T}}, ch_basis.cartan),
62+
convert(Vector{Vector{T}}, ch_basis.positive),
63+
convert(Vector{Vector{T}}, ch_basis.negative),
64+
ch_basis.positive_roots,
65+
ch_basis.negative_roots
66+
)
67+
4468

45-
struct ReductiveLieAlgebra{T, W} <: AbstractReductiveLieAlgebra
69+
struct ReductiveLieAlgebra{F, W} <: AbstractReductiveLieAlgebra
4670
name::String
47-
basis::ChevalleyBasis{T}
48-
weight_structure::WeightStructure{MatrixVectorSpace{T}, W}
49-
hw_spaces::Vector{WeightSpace{MatrixVectorSpace{T}, W}}
71+
basis::ChevalleyBasis{F}
72+
weight_structure::WeightStructure{F, MatrixVectorSpace{F}, W}
73+
hw_spaces::Vector{WeightSpace{F, MatrixVectorSpace{F}, W}}
5074
end
5175

5276
function so3_lie_algebra()
@@ -58,10 +82,10 @@ function so3_lie_algebra()
5882
negative = [[im, 1, 0]] # J₋
5983
pos_roots = [[1]]
6084
neg_roots = [[-1]]
61-
ch_basis = ChevalleyBasis{Complex{Rational{Int}}}([X₁, X₂, X₃], cartan, positive, negative, pos_roots, neg_roots)
85+
ch_basis = ChevalleyBasis([X₁, X₂, X₃], cartan, positive, negative, pos_roots, neg_roots)
6286
ws = WeightStructure([[-1], [0], [1]], [[1, -im, 0], [0, 0, 1], [1, im, 0]])
6387
hw_spaces = [WeightSpace([1], [1, im, 0])]
64-
return ReductiveLieAlgebra("𝖘𝖔(3,ℂ)", ch_basis, ws, hw_spaces)
88+
return ReductiveLieAlgebra{Complex{Rational{Int}}, Int}("𝖘𝖔(3)", ch_basis, ws, hw_spaces)
6589
end
6690

6791
# TODO
@@ -78,8 +102,10 @@ dim(alg::ReductiveLieAlgebra) = length(alg.basis.std_basis)
78102
rank(alg::ReductiveLieAlgebra) = length(alg.basis.cartan)
79103
Base.size(alg::ReductiveLieAlgebra) = size(alg.basis.std_basis[1], 1)
80104

81-
function Base.show(io::IO, alg::ReductiveLieAlgebra)
105+
function Base.show(io::IO, alg::ReductiveLieAlgebra{F, W}) where {F, W}
82106
println(io, "ReductiveLieAlgebra $(name(alg))")
107+
println(io, " field (or number type): $(F)")
108+
println(io, " weight type: Vector{$(W)}")
83109
println(io, " dimension: $(dim(alg))")
84110
print(io, " rank (dimension of Cartan subalgebra): $(rank(alg))")
85111
end

src/lie-groups/lie-algebras/weights.jl

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,53 @@ end
1818
weight(wv::WeightVector) = wv.weight
1919
vector(wv::WeightVector) = wv.vector
2020

21-
struct WeightSpace{T <: AbstractVectorSpace, W} # TODO: <: AbstractVectorSpace?
21+
struct WeightSpace{F, T <: AbstractVectorSpace{F}, W} # TODO: <: AbstractVectorSpace?
2222
weight::Weight{W}
2323
space::T
2424
end
2525

26-
WeightSpace{T, W}(
27-
w::Vector{W},
28-
v::Vector
29-
) where {T <: AbstractVectorSpace, W} = WeightSpace(Weight(w), T(V2M(v)))
26+
WeightSpace(weight::Vector, space::Vector) = WeightSpace(Weight(weight), MatrixVectorSpace(space))
3027

31-
WeightSpace(
32-
w::Vector{W},
33-
v::Vector
34-
) where {W} = WeightSpace{MatrixVectorSpace, W}(w, v)
28+
Base.convert(
29+
::Type{WeightSpace{F, T, W}},
30+
ws::WeightSpace
31+
) where {F, T<:AbstractVectorSpace{F}, W} = WeightSpace(
32+
convert(Weight{W}, weight(ws)),
33+
convert(T, space(ws))
34+
)
3535

3636
weight(ws::WeightSpace) = ws.weight
3737
space(ws::WeightSpace) = ws.space
3838
dim(ws::WeightSpace) = dim(space(ws))
3939

40-
struct WeightStructure{T<:AbstractVectorSpace, W}
40+
struct WeightStructure{F, T<:AbstractVectorSpace{F}, W}
4141
weights::Vector{Weight{W}}
42-
dict::Dict{Weight{W}, WeightSpace{T, W}}
42+
dict::Dict{Weight{W}, WeightSpace{F, T, W}}
4343
end
4444

45-
WeightStructure{T, W}(
46-
weights::Vector{Weight{W}},
47-
weight_spaces::Vector{<:Matrix}
48-
) where {T <: AbstractVectorSpace, W} = WeightStructure(
45+
WeightStructure(
46+
weights::Vector{<:Weight},
47+
weight_spaces::Vector{<:MatrixVectorSpace}
48+
) = WeightStructure(
4949
weights,
50-
Dict(zip(weights, [WeightSpace(w, T(M)) for (w, M) in zip(weights, weight_spaces)]))
50+
Dict(zip(weights, [WeightSpace(w, V) for (w, V) in zip(weights, weight_spaces)]))
5151
)
5252

5353
WeightStructure(
54-
weights::Vector{Vector{W}},
54+
weights::Vector{<:Vector},
5555
weight_vectors::Vector{<:Vector}
56-
) where {W} = WeightStructure{MatrixVectorSpace, W}([Weight(w) for w in weights], [V2M(v) for v in weight_vectors])
56+
) = WeightStructure(
57+
[Weight(w) for w in weights],
58+
[MatrixVectorSpace(v) for v in weight_vectors]
59+
)
60+
61+
Base.convert(
62+
::Type{WeightStructure{F, T, W}},
63+
ws::WeightStructure
64+
) where {F, T<:AbstractVectorSpace{F}, W} = WeightStructure(
65+
convert(Vector{Weight{W}}, ws.weights),
66+
convert(Dict{Weight{W}, WeightSpace{F, T, W}}, ws.dict)
67+
)
5768

5869
weights(ws::WeightStructure) = ws.weights
5970
nweights(ws::WeightStructure) = length(ws.weights)

src/types.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,30 @@ abstract type AbstractLieAlgebraElem end
3131
algebra(::AbstractLieAlgebraElem) = error("Not implemented")
3232

3333

34-
abstract type AbstractVectorSpace end
34+
abstract type AbstractVectorSpace{F} end
3535

3636
name(::AbstractVectorSpace) = error("Not implemented")
3737
basis(::AbstractVectorSpace) = error("Not implemented")
3838
dim(::AbstractVectorSpace) = error("Not implemented")
3939

4040

41-
abstract type AbstractDirectSum <: AbstractVectorSpace end
41+
abstract type AbstractDirectSum{F} <: AbstractVectorSpace{F} end
4242

4343
spaces(::AbstractDirectSum) = error("Not implemented")
4444

4545

46-
abstract type AbstractSymmetricPower <: AbstractVectorSpace end
46+
abstract type AbstractSymmetricPower{F} <: AbstractVectorSpace{F} end
4747

4848
base_space(::AbstractSymmetricPower) = error("Not implemented")
4949
power(::AbstractSymmetricPower) = error("Not implemented")
5050

5151

52-
abstract type AbstractTensorProduct <: AbstractVectorSpace end
52+
abstract type AbstractTensorProduct{F} <: AbstractVectorSpace{F} end
5353

5454
spaces(::AbstractTensorProduct) = error("Not implemented")
5555

5656

57-
abstract type AbstractRepresentation{T<:AbstractReductiveGroup, S<:AbstractVectorSpace} end
57+
abstract type AbstractRepresentation{F, T<:AbstractReductiveGroup, S<:AbstractVectorSpace{F}} end
5858

5959
group(::AbstractRepresentation) = error("Not implemented")
6060
action(::AbstractRepresentation) = error("Not implemented")

src/vector_spaces.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ export MatrixVectorSpace,
22
VectorSpace
33

44

5-
struct MatrixVectorSpace{T} <: AbstractVectorSpace
5+
struct MatrixVectorSpace{T} <: AbstractVectorSpace{T}
66
basis::Matrix{T}
77
end
88

9+
MatrixVectorSpace(v::Vector) = MatrixVectorSpace(V2M(v))
910

10-
struct VectorSpace{T} <: AbstractVectorSpace
11+
basis(V::MatrixVectorSpace) = V.basis
12+
Base.convert(
13+
::Type{MatrixVectorSpace{T}},
14+
V::MatrixVectorSpace
15+
) where {T} = MatrixVectorSpace(convert(Matrix{T}, basis(V)))
16+
17+
struct VectorSpace{T} <: AbstractVectorSpace{T}
1118
basis::Vector{T}
1219
end

0 commit comments

Comments
 (0)