@@ -2,7 +2,8 @@ export AbstractLieAlgebraAction,
22 LieAlgebraAction,
33 ScalingLieAction,
44 SumLieAlgebraAction,
5- var_groups
5+ var_groups,
6+ hw_spaces
67
78
89abstract type AbstractLieAlgebraAction end
@@ -26,22 +27,22 @@ function ScalingLieAction(action_vars::AbstractArray; variables::AbstractArray=a
2627 return ScalingLieAction (act_vars, all_vars)
2728end
2829
29- algebra (g :: ScalingLieAction ) = g . alg
30- variables (g :: ScalingLieAction ) = g . vars
31- exponents (g :: ScalingLieAction ) = g . alg. exps
30+ algebra (a :: ScalingLieAction ) = a . alg
31+ variables (a :: ScalingLieAction ) = a . vars
32+ exponents (a :: ScalingLieAction ) = a . alg. exps
3233
33- function Base. show (io:: IO , g :: ScalingLieAction )
34- println (io, " ScalingLieAction of $(name (algebra (g ))) " )
34+ function Base. show (io:: IO , a :: ScalingLieAction )
35+ println (io, " ScalingLieAction of $(name (algebra (a ))) " )
3536 print (io, " action:" )
36- U = exponents (g )
37+ U = exponents (a )
3738 if size (U, 1 ) == 1
3839 @var λ
3940 λ = [λ]
4041 else
4142 @var λ[1 : size (U₀, 1 )]
4243 end
4344 action = Vector {Vector{Tuple{Variable, Expression}}} ([[] for _ in axes (U, 1 )])
44- vars = variables (g )
45+ vars = variables (a )
4546 for j in axes (U, 1 )
4647 nzind, nzval = findnz (U[j, :])
4748 exprs = (λ[j]. ^ nzval). * vars[nzind]
@@ -56,6 +57,44 @@ function Base.show(io::IO, g::ScalingLieAction)
5657 end
5758end
5859
60+ function act (elem:: LieAlgebraElem{ScalingLieAlgebra} , f:: Union{Expression, Monomial} , action:: ScalingLieAction )
61+ X = as_matrix (elem)
62+ return expand (dot (differentiate (f, variables (action)), - X* variables (action)))
63+ end
64+
65+ function weight_structure (a:: ScalingLieAction , vars:: Vector{Variable} )
66+
67+ end
68+
69+ function hw_spaces (a:: ScalingLieAction , vars:: Vector{Variable} )
70+ @assert variables (a) ⊆ vars
71+ vars_dict = Dict (zip (vars, 1 : length (vars)))
72+ hw_spaces_dict = Dict {Vector{Int}, WeightSpace} ()
73+ for (i, var) in enumerate (variables (a))
74+ weight = exponents (a)[:, i]
75+ if haskey (hw_spaces_dict, weight)
76+ sp = zeros (ComplexF64, length (vars))
77+ sp[vars_dict[var]] = 1
78+ hw_spaces_dict[weight]. space = hcat (hw_spaces_dict[weight]. space, sp)
79+ else
80+ hw_space = WeightSpace (weight, zeros (ComplexF64, length (vars)))
81+ hw_space. space[vars_dict[var]] = 1
82+ hw_spaces_dict[weight] = hw_space
83+ end
84+ end
85+ inv_vars = setdiff (vars, variables (a))
86+ isempty (inv_vars) && return collect (values (hw_spaces_dict))
87+ inv_hw_space = WeightSpace (zeros (Int, rank (algebra (a))), zeros (ComplexF64, length (vars), length (inv_vars)))
88+ for (i, var) in enumerate (inv_vars)
89+ inv_hw_space. space[vars_dict[var], i] = 1
90+ end
91+ if haskey (hw_spaces_dict, weight (inv_hw_space))
92+ hw_spaces_dict[weight (inv_hw_space)]. space = hcat (hw_spaces_dict[weight (inv_hw_space)]. space, inv_hw_space. space)
93+ else
94+ hw_spaces_dict[weight (inv_hw_space)] = inv_hw_space
95+ end
96+ return collect (values (hw_spaces_dict))
97+ end
5998
6099struct LieAlgebraAction <: AbstractLieAlgebraAction
61100 alg:: LieAlgebra
@@ -72,16 +111,54 @@ LieAlgebraAction(
72111 var_groups:: AbstractArray
73112) = LieAlgebraAction (alg, M2VV (hcat (var_groups... )))
74113
75- algebra (g:: LieAlgebraAction ) = g. alg
76- var_groups (g:: LieAlgebraAction ) = g. var_groups
77- variables (g:: LieAlgebraAction ) = vcat (var_groups (g)... )
78- weights (g:: LieAlgebraAction ) = weights (g. alg)
79- weights (g:: LieAlgebraAction , inds... ) = weights (g. alg, inds... )
80- nweights (g:: LieAlgebraAction ) = nweights (g. alg)
114+ algebra (a:: LieAlgebraAction ) = a. alg
115+ var_groups (a:: LieAlgebraAction ) = a. var_groups
116+ nvar_groups (a:: LieAlgebraAction ) = length (var_groups (a))
117+ variables (a:: LieAlgebraAction ) = vcat (var_groups (a)... )
118+ weights (a:: LieAlgebraAction ) = weights (a. alg)
119+ weights (a:: LieAlgebraAction , inds... ) = weights (a. alg, inds... )
120+ nweights (a:: LieAlgebraAction ) = nweights (a. alg)
121+
122+ function Base. show (io:: IO , a:: LieAlgebraAction )
123+ println (io, " LieAlgebraAction of $(name (algebra (a))) " )
124+ print (io, " action: [" , join ([join (vars, " , " ) for vars in var_groups (a)], " ], [" ), " ]" )
125+ end
81126
82- function Base. show (io:: IO , g:: LieAlgebraAction )
83- println (io, " LieAlgebraAction of $(name (algebra (g))) " )
84- print (io, " action: [" , join ([join (vars, " , " ) for vars in var_groups (g)], " ], [" ), " ]" )
127+ function act (elem:: LieAlgebraElem{LieAlgebra} , f:: Union{Expression, Monomial} , action:: LieAlgebraAction )
128+ X = as_matrix (elem)
129+ return expand (sum ([dot (differentiate (f, vars), - X* vars) for vars in var_groups (action)]))
130+ end
131+
132+ function weight_structure (a:: LieAlgebraAction , vars:: Vector{Variable} )
133+
134+ end
135+
136+ function hw_spaces (a:: LieAlgebraAction , vars:: Vector{Variable} )
137+ @assert variables (a) ⊆ vars
138+ vars_dict = Dict (zip (vars, 1 : length (vars)))
139+ hw_spaces_vec = WeightSpace[]
140+ for hw_space in hw_spaces (algebra (a))
141+ hws = WeightSpace (hw_space. weight, zeros (ComplexF64, length (vars), dim (hw_space)* nvar_groups (a)))
142+ for (i, vars_group) in enumerate (var_groups (a))
143+ for (j, var) in enumerate (vars_group)
144+ hws. space[vars_dict[var], (i- 1 )* dim (hw_space)+ 1 : i* dim (hw_space)] = hw_space. space[j, :]
145+ end
146+ end
147+ push! (hw_spaces_vec, hws)
148+ end
149+ inv_vars = setdiff (vars, variables (a))
150+ isempty (inv_vars) && return hw_spaces_vec
151+ inv_hw_space = WeightSpace (zeros (Int, rank (algebra (a))), zeros (ComplexF64, length (vars), length (inv_vars)))
152+ for (i, var) in enumerate (inv_vars)
153+ inv_hw_space. space[vars_dict[var], i] = 1
154+ end
155+ hws_dict = Dict (zip ([weight (hws) for hws in hw_spaces_vec], hw_spaces_vec))
156+ if haskey (hws_dict, weight (inv_hw_space))
157+ hws_dict[weight (inv_hw_space)]. space = hcat (hws_dict[weight (inv_hw_space)]. space, inv_hw_space. space)
158+ else
159+ push! (hw_spaces_vec, inv_hw_space)
160+ end
161+ return hw_spaces_vec
85162end
86163
87164
@@ -90,13 +167,13 @@ struct SumLieAlgebraAction <: AbstractLieAlgebraAction
90167 actions:: Vector{AbstractLieAlgebraAction}
91168end
92169
93- algebra (g :: SumLieAlgebraAction ) = g . alg
94- actions (g :: SumLieAlgebraAction ) = g . actions
95- nsummands (g :: SumLieAlgebraAction ) = length (actions (g ))
96- Base. getindex (g :: SumLieAlgebraAction , i:: Int ) = actions (g )[i]
170+ algebra (a :: SumLieAlgebraAction ) = a . alg
171+ actions (a :: SumLieAlgebraAction ) = a . actions
172+ nsummands (a :: SumLieAlgebraAction ) = length (actions (a ))
173+ Base. getindex (a :: SumLieAlgebraAction , i:: Int ) = actions (a )[i]
97174
98- function Base. show (io:: IO , g :: SumLieAlgebraAction )
99- println (io, " SumLieAlgebraAction of $(name (algebra (g ))) " )
175+ function Base. show (io:: IO , a :: SumLieAlgebraAction )
176+ println (io, " SumLieAlgebraAction of $(name (algebra (a ))) " )
100177 # for (i, a) in enumerate(actions(g))
101178 # print(io, " action of $(name(algebra(a))): [")
102179 # print(io, join([join(vars, ", ") for vars in var_groups(a)], "], ["), "]")
@@ -106,36 +183,45 @@ function Base.show(io::IO, g::SumLieAlgebraAction)
106183end
107184
108185# TODO
109- function are_commutative (g ₁:: AbstractLieAlgebraAction , g ₂:: AbstractLieAlgebraAction )
186+ function are_commutative (a ₁:: AbstractLieAlgebraAction , a ₂:: AbstractLieAlgebraAction )
110187 return true
111188end
112189
113- function ⊕ (g₁:: AbstractLieAlgebraAction , g₂:: AbstractLieAlgebraAction )
114- @assert are_commutative (g₁, g₂)
115- alg = algebra (g₁) ⊕ algebra (g₂)
116- return SumLieAlgebraAction (alg, [g₁, g₂])
117- end
118-
119- function ⊕ (g₁:: SumLieAlgebraAction , g₂:: AbstractLieAlgebraAction )
120- @assert are_commutative (g₁, g₂)
121- alg = algebra (g₁) ⊕ algebra (g₂)
122- return SumLieAlgebraAction (alg, [actions (g₁)... , g₂])
123- end
124-
125- function act (elem:: LieAlgebraElem{LieAlgebra} , f:: Union{Expression, Monomial} , action:: LieAlgebraAction )
126- X = as_matrix (elem)
127- return expand (sum ([dot (differentiate (f, vars), - X* vars) for vars in var_groups (action)]))
190+ function ⊕ (a₁:: AbstractLieAlgebraAction , a₂:: AbstractLieAlgebraAction )
191+ @assert are_commutative (a₁, a₂)
192+ alg = algebra (a₁) ⊕ algebra (a₂)
193+ return SumLieAlgebraAction (alg, [a₁, a₂])
128194end
129195
130- function act (elem:: LieAlgebraElem{ScalingLieAlgebra} , f:: Union{Expression, Monomial} , action:: ScalingLieAction )
131- X = as_matrix (elem)
132- return expand (dot (differentiate (f, variables (action)), - X* variables (action)))
196+ function ⊕ (a₁:: SumLieAlgebraAction , a₂:: AbstractLieAlgebraAction )
197+ @assert are_commutative (a₁, a₂)
198+ alg = algebra (a₁) ⊕ algebra (a₂)
199+ return SumLieAlgebraAction (alg, [actions (a₁)... , a₂])
133200end
134201
135202function act (elem:: SumLieAlgebraElem , f:: Union{Expression, Monomial} , action:: SumLieAlgebraAction )
136203 return expand (sum ([act (elem[i], f, action[i]) for i in 1 : nsummands (action)]))
137204end
138205
206+ hw_spaces (
207+ a:: SumLieAlgebraAction ,
208+ vars:: Vector{Variable}
209+ ) = ∩ ([hw_spaces (action, vars) for action in actions (a)])
210+
211+ function weight_structure (a:: AbstractLieAlgebraAction , vars:: Vector{Variable} )
212+ hws = hw_spaces (a, vars)
213+ mons = MonomialBasis {Int8,Int16} (vars, degree= 1 , upto= false )
214+ ws = WeightStructure ()
215+ for hw_space in hws
216+ for hwv in hw_space
217+ wexpr = WeightExpression (hwv, mons)
218+ orb = orbit (wexpr, a)
219+ [push! (ws, WeightVector (we)) for we in orb]
220+ end
221+ end
222+ return ws
223+ end
224+
139225function as_matrix (elem:: AbstractLieAlgebraElem , B:: MonomialBasis , action:: AbstractLieAlgebraAction )
140226 @assert algebra (elem) == algebra (action)
141227 M = zeros (ComplexF64, length (B), length (B))
0 commit comments