X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Fhurwitz.py;h=cad89ca177cbdcfbc065682d4a64af43aad6917a;hb=f721f283cea741c54e4a2b26d63094dd6c396c6a;hp=1f7c9dc3781a844d6d77a1e63168c52340bf6770;hpb=fc29add6cf1d9ff4e8a240b0f8f2ca6672d4ea57;p=sage.d.git diff --git a/mjo/hurwitz.py b/mjo/hurwitz.py index 1f7c9dc..cad89ca 100644 --- a/mjo/hurwitz.py +++ b/mjo/hurwitz.py @@ -319,6 +319,7 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement): sage: A = HurwitzMatrixAlgebra(2, QQbar, ZZ) sage: M = A([ [ I, 2*I], ....: [ 3*I, 4*I] ]) + sage: M.conjugate_transpose() +------+------+ | -1*I | -3*I | +------+------+ @@ -626,6 +627,32 @@ class QuaternionMatrixAlgebra(HurwitzMatrixAlgebra): entry_algebra = QuaternionAlgebra(scalars,-1,-1) super().__init__(n, entry_algebra, scalars, **kwargs) + def _entry_algebra_element_to_vector(self, entry): + r""" + + SETUP:: + + sage: from mjo.hurwitz import QuaternionMatrixAlgebra + + EXAMPLES:: + + sage: A = QuaternionMatrixAlgebra(2) + sage: u = A.entry_algebra().one() + sage: A._entry_algebra_element_to_vector(u) + (1, 0, 0, 0) + sage: i,j,k = A.entry_algebra().gens() + sage: A._entry_algebra_element_to_vector(i) + (0, 1, 0, 0) + sage: A._entry_algebra_element_to_vector(j) + (0, 0, 1, 0) + sage: A._entry_algebra_element_to_vector(k) + (0, 0, 0, 1) + + """ + from sage.modules.free_module import VectorSpace + d = len(self.entry_algebra_gens()) + V = VectorSpace(self.entry_algebra().base_ring(), d) + return V(entry.coefficient_tuple()) class ComplexMatrixAlgebra(HurwitzMatrixAlgebra): r""" @@ -706,3 +733,24 @@ class ComplexMatrixAlgebra(HurwitzMatrixAlgebra): from sage.rings.all import QQbar entry_algebra = QQbar super().__init__(n, entry_algebra, scalars, **kwargs) + + def _entry_algebra_element_to_vector(self, entry): + r""" + + SETUP:: + + sage: from mjo.hurwitz import ComplexMatrixAlgebra + + EXAMPLES:: + + sage: A = ComplexMatrixAlgebra(2, QQbar, QQ) + sage: A._entry_algebra_element_to_vector(QQbar(1)) + (1, 0) + sage: A._entry_algebra_element_to_vector(QQbar(I)) + (0, 1) + + """ + from sage.modules.free_module import VectorSpace + d = len(self.entry_algebra_gens()) + V = VectorSpace(self.entry_algebra().base_ring(), d) + return V((entry.real(), entry.imag()))