From: Michael Orlitzky Date: Mon, 8 Mar 2021 16:30:08 +0000 (-0500) Subject: octonions: add QuaternionMatrixAlgebra; prepare for rename... X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=2d94a6ffbaacfc4d63ec47580d0caa1ae6c02e07;p=sage.d.git octonions: add QuaternionMatrixAlgebra; prepare for rename... --- diff --git a/mjo/octonions.py b/mjo/octonions.py index 2850545..78365e2 100644 --- a/mjo/octonions.py +++ b/mjo/octonions.py @@ -354,11 +354,11 @@ class OctonionMatrixAlgebra(HurwitzMatrixAlgebra): The usual matrix spaces in SageMath don't support octonion entries because they assume that the entries of the matrix come from a - commutative and associative ring (i.e. very NOT the octonions). + commutative and associative ring, and the octonions are neither. SETUP:: - sage: from mjo.octonions import Octonions, OctonionMatrixAlgebra + sage: from mjo.octonions import OctonionMatrixAlgebra EXAMPLES:: @@ -371,11 +371,10 @@ class OctonionMatrixAlgebra(HurwitzMatrixAlgebra): :: - sage: O = Octonions(QQ) - sage: e0,e1,e2,e3,e4,e5,e6,e7 = O.gens() - sage: MS = OctonionMatrixAlgebra(2) - sage: MS([ [e0+e4, e1+e5], - ....: [e2-e6, e3-e7] ]) + sage: A = OctonionMatrixAlgebra(2) + sage: e0,e1,e2,e3,e4,e5,e6,e7 = A.entry_algebra().gens() + sage: A([ [e0+e4, e1+e5], + ....: [e2-e6, e3-e7] ]) +---------+---------+ | e0 + e4 | e1 + e5 | +---------+---------+ @@ -395,9 +394,9 @@ class OctonionMatrixAlgebra(HurwitzMatrixAlgebra): TESTS:: sage: set_random_seed() - sage: MS = OctonionMatrixAlgebra(ZZ.random_element(10)) - sage: x = MS.random_element() - sage: x*MS.one() == x and MS.one()*x == x + sage: A = OctonionMatrixAlgebra(ZZ.random_element(10)) + sage: x = A.random_element() + sage: x*A.one() == x and A.one()*x == x True """ @@ -407,3 +406,64 @@ class OctonionMatrixAlgebra(HurwitzMatrixAlgebra): n, prefix=prefix, **kwargs) + +class QuaternionMatrixAlgebra(HurwitzMatrixAlgebra): + r""" + The algebra of ``n``-by-``n`` matrices with quaternion entries over + (a subfield of) the real numbers. + + The usual matrix spaces in SageMath don't support quaternion entries + because they assume that the entries of the matrix come from a + commutative ring, and the quaternions are not commutative. + + SETUP:: + + sage: from mjo.octonions import QuaternionMatrixAlgebra + + EXAMPLES:: + + sage: QuaternionMatrixAlgebra(3) + Module of 3 by 3 matrices with entries in Quaternion + Algebra (-1, -1) with base ring Algebraic Real Field + over the scalar ring Algebraic Real Field + sage: QuaternionMatrixAlgebra(3,QQ) + Module of 3 by 3 matrices with entries in Quaternion + Algebra (-1, -1) with base ring Rational Field over + the scalar ring Rational Field + + :: + + sage: A = QuaternionMatrixAlgebra(2) + sage: i,j,k = A.entry_algebra().gens() + sage: A([ [1+i, j-2], + ....: [k, k+j] ]) + +-------+--------+ + | 1 + i | -2 + j | + +-------+--------+ + | k | j + k | + +-------+--------+ + + :: + + sage: A1 = QuaternionMatrixAlgebra(1,QQ) + sage: A2 = QuaternionMatrixAlgebra(2,QQ) + sage: cartesian_product([A1,A2]) + Module of 1 by 1 matrices with entries in Quaternion Algebra + (-1, -1) with base ring Rational Field over the scalar ring + Rational Field (+) Module of 2 by 2 matrices with entries in + Quaternion Algebra (-1, -1) with base ring Rational Field over + the scalar ring Rational Field + + TESTS:: + + sage: set_random_seed() + sage: A = QuaternionMatrixAlgebra(ZZ.random_element(10)) + sage: x = A.random_element() + sage: x*A.one() == x and A.one()*x == x + True + + """ + def __init__(self, n, scalars=AA, **kwargs): + # The -1,-1 gives us the "usual" definition of quaternion + Q = QuaternionAlgebra(scalars,-1,-1) + super().__init__(Q, scalars, n, **kwargs)