+ def __init__(self, n, field=AA, prefix="E", **kwargs):
+ # Not associative, not commutative
+ category = MagmaticAlgebras(field).FiniteDimensional()
+ category = category.WithBasis().Unital()
+
+ self._nrows = n
+
+ # Since the scalar field is real but the entries are octonion,
+ # sticking a "1" in each position doesn't give us a basis for
+ # the space. We actually need to stick each of e0, e1, ..., e7
+ # (a basis for the Octonions themselves) into each position.
+ from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
+ from sage.categories.sets_cat import cartesian_product
+
+ I = FiniteEnumeratedSet(range(n))
+ J = FiniteEnumeratedSet(range(n))
+ self._octonions = Octonions(field=field)
+ entry_basis = self._octonions.gens()
+
+ basis_indices = cartesian_product([I,J,entry_basis])
+ super().__init__(field,
+ basis_indices,
+ category=category,
+ prefix=prefix,
+ bracket='(')
+
+ def _repr_(self):
+ return ("Module of %d by %d matrices with octonion entries"
+ " over the scalar ring %s" %
+ (self.nrows(), self.ncols(), self.base_ring()) )
+
+ def octonions(self):