- 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):
- r"""
- Return the Octonion algebra that our elements' entries come from.
- """
- return self._octonions
-
- def nrows(self):
- return self._nrows
- ncols = nrows
-
- def product_on_basis(self, mon1, mon2):
- (i,j,oct1) = mon1
- (k,l,oct2) = mon2
- if j == k:
- return self.monomial((i,l,oct1*oct2))
- else:
- return self.zero()
-
- def one(self):
- r"""
- SETUP::
-
- sage: from mjo.octonions import OctonionMatrixAlgebra
-
- 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
- True
-
- """
- return sum( (self.monomial((i,i,self._octonions.one()))
- for i in range(self.nrows()) ),
- self.zero() )
-
- def from_list(self, entries):
- r"""
- Construct an element of this algebra from a list of lists of
- octonions.
-
- SETUP::
-
- sage: from mjo.octonions import Octonions, OctonionMatrixAlgebra
-
- EXAMPLES::
-
- sage: O = Octonions(QQ)
- sage: e0,e1,e2,e3,e4,e5,e6,e7 = O.gens()
- sage: MS = OctonionMatrixAlgebra(2)
- sage: MS.from_list([ [e0+e4, e1+e5],
- ....: [e2-e6, e3-e7] ])
- +---------+---------+
- | e0 + e4 | e1 + e5 |
- +---------+---------+
- | e2 - e6 | e3 - e7 |
- +---------+---------+
-
- """
- nrows = len(entries)
- ncols = 0
- if nrows > 0:
- ncols = len(entries[0])
-
- if (not all( len(r) == ncols for r in entries )) or (ncols != nrows):
- raise ValueError("list must be square")
-
- def convert(e_ij):
- # We have to pass through vectors to convert from the
- # given octonion algebra to ours. Otherwise we can fail
- # to convert an element of (for example) Octonions(QQ)
- # to Octonions(AA).
- return self.octonions().from_vector(e_ij.to_vector())
-
- return sum( (self.monomial( (i,j, convert(entries[i][j])) )
- for i in range(nrows)
- for j in range(ncols) ),
- self.zero() )