Skip to content

Commit

Permalink
Trac #25008: Additional method "matrix" / "_matrix_" for the element …
Browse files Browse the repository at this point in the history
…class of ClassicalMatrixLieAlgebra

A method to obtain the underlying matrix as element of the corresponding
full matrix space analog to the similar method of
MatrixGroupElement_generic should be added. This may be a shortcut for
the following:

{{{
sage: LM = lie_algebras.sp(QQ, 4, representation='matrix')
sage: e1, e2, f1, f2, h1, h2 = LM.gens()
sage: mh1 = LM.associative_algebra()(dict(h1)); mh1
[ 1  0  0  0]
[ 0 -1  0  0]
[ 0  0 -1  0]
[ 0  0  0  1]
sage: mh1.parent()
Full MatrixSpace of 4 by 4 sparse matrices over Rational Field
}}}

URL: https://trac.sagemath.org/25008
Reported by: soehms
Ticket author(s): Sebastian Oehms
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed May 10, 2018
2 parents dd67e2a + f1d16d1 commit 05f9233
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/sage/algebras/lie_algebras/classical_lie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
AUTHORS:
- Travis Scrimshaw (2013-05-03): Initial version
- Sebastian Oehms (2018-03-18): matrix method of the element class of ClassicalMatrixLieAlgebra added
"""

#*****************************************************************************
Expand Down Expand Up @@ -333,6 +334,42 @@ def affine(self, kac_moody=False):
from sage.algebras.lie_algebras.affine_lie_algebra import AffineLieAlgebra
return AffineLieAlgebra(self, kac_moody)

class Element(LieAlgebraFromAssociative.Element):
def matrix(self):
r"""
Return ``self`` as element of the underlying matrix algebra.
OUTPUT:
An instance of the element class of MatrixSpace.
EXAMPLES::
sage: sl3m = lie_algebras.sl(ZZ, 3, representation='matrix')
sage: e1,e2, f1, f2, h1, h2 = sl3m.gens()
sage: h1m = h1.matrix(); h1m
[ 1 0 0]
[ 0 -1 0]
[ 0 0 0]
sage: h1m.parent()
Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring
sage: matrix(h2)
[ 0 0 0]
[ 0 1 0]
[ 0 0 -1]
sage: L = lie_algebras.so(QQ['z'], 5, representation='matrix')
sage: matrix(L.an_element())
[ 1 1 0 0 0]
[ 1 1 0 0 2]
[ 0 0 -1 -1 0]
[ 0 0 -1 -1 -1]
[ 0 1 0 -2 0]
"""
return self.value

_matrix_ = matrix


class gl(LieAlgebraFromAssociative):
r"""
The matrix Lie algebra `\mathfrak{gl}_n`.
Expand Down Expand Up @@ -460,7 +497,7 @@ def monomial(self, i):
return self.basis()['E_{}_{}'.format(*i)]
return self.basis()[i]

class Element(LieAlgebraFromAssociative.Element):
class Element(ClassicalMatrixLieAlgebra.Element):
def monomial_coefficients(self, copy=True):
r"""
Return the monomial coefficients of ``self``.
Expand Down

0 comments on commit 05f9233

Please sign in to comment.