from sage.matrix.matrix_space import MatrixSpace
from sage.misc.table import table
-from mjo.matrix_algebra import HurwitzMatrixAlgebra
+from mjo.matrix_algebra import MatrixAlgebra, MatrixAlgebraElement
class Octonion(IndexedFreeModuleElement):
def conjugate(self):
r"""
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
r"""
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES::
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
TESTS:
SETUP::
- sage: from mjo.octonions import Octonions
+ sage: from mjo.hurwitz import Octonions
EXAMPLES:
+
+
+class HurwitzMatrixAlgebraElement(MatrixAlgebraElement):
+ def is_hermitian(self):
+ r"""
+
+ SETUP::
+
+ sage: from mjo.hurwitz import HurwitzMatrixAlgebra
+
+ EXAMPLES::
+
+ sage: A = HurwitzMatrixAlgebra(QQbar, ZZ, 2)
+ sage: M = A([ [ 0,I],
+ ....: [-I,0] ])
+ sage: M.is_hermitian()
+ True
+
+ """
+ return all( self[i,j] == self[j,i].conjugate()
+ for i in range(self.nrows())
+ for j in range(self.ncols()) )
+
+
+class HurwitzMatrixAlgebra(MatrixAlgebra):
+ r"""
+ A class of matrix algebras whose entries come from a Hurwitz
+ algebra.
+
+ For our purposes, we consider "a Hurwitz" algebra to be the real
+ or complex numbers, the quaternions, or the octonions. These are
+ typically also referred to as the Euclidean Hurwitz algebras, or
+ the normed division algebras.
+
+ By the Cayley-Dickson construction, each Hurwitz algebra is an
+ algebra over the real numbers, so we restrict the scalar field in
+ this case to be real. This also allows us to more accurately
+ produce the generators of the matrix algebra.
+ """
+ Element = HurwitzMatrixAlgebraElement
+
+ def __init__(self, entry_algebra, scalars, n, **kwargs):
+ from sage.rings.all import RR
+ if not scalars.is_subring(RR):
+ # Not perfect, but it's what we're using.
+ raise ValueError("scalar field is not real")
+
+ super().__init__(entry_algebra, scalars, n, **kwargs)
+
+ def entry_algebra_gens(self):
+ r"""
+ Return the generators of (that is, a basis for) the entries of
+ this matrix algebra.
+
+ This works around the inconsistency in the ``gens()`` methods
+ of the real/complex numbers, quaternions, and octonions.
+
+ SETUP::
+
+ sage: from mjo.hurwitz import Octonions, HurwitzMatrixAlgebra
+
+ EXAMPLES:
+
+ The inclusion of the unit element is inconsistent across
+ (subalgebras of) Hurwitz algebras::
+
+ sage: AA.gens()
+ (1,)
+ sage: QQbar.gens()
+ (I,)
+ sage: QuaternionAlgebra(AA,1,-1).gens()
+ [i, j, k]
+ sage: Octonions().gens()
+ (e0, e1, e2, e3, e4, e5, e6, e7)
+
+ The unit element is always returned by this method, so the
+ sets of generators have cartinality 1,2,4, and 8 as you'd
+ expect::
+
+ sage: HurwitzMatrixAlgebra(AA, AA, 2).entry_algebra_gens()
+ (1,)
+ sage: HurwitzMatrixAlgebra(QQbar, AA, 2).entry_algebra_gens()
+ (1, I)
+ sage: Q = QuaternionAlgebra(AA,-1,-1)
+ sage: HurwitzMatrixAlgebra(Q, AA, 2).entry_algebra_gens()
+ (1, i, j, k)
+ sage: O = Octonions()
+ sage: HurwitzMatrixAlgebra(O, AA, 2).entry_algebra_gens()
+ (e0, e1, e2, e3, e4, e5, e6, e7)
+
+ """
+ gs = self.entry_algebra().gens()
+ one = self.entry_algebra().one()
+ if one in gs:
+ return gs
+ else:
+ return (one,) + tuple(gs)
+
+
+
class OctonionMatrixAlgebra(HurwitzMatrixAlgebra):
r"""
The algebra of ``n``-by-``n`` matrices with octonion entries over
SETUP::
- sage: from mjo.octonions import OctonionMatrixAlgebra
+ sage: from mjo.hurwitz import OctonionMatrixAlgebra
EXAMPLES::
SETUP::
- sage: from mjo.octonions import QuaternionMatrixAlgebra
+ sage: from mjo.hurwitz import QuaternionMatrixAlgebra
EXAMPLES::