X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=mjo%2Foctonions.py;h=a5f6dec0239f5f3e084fb4c1c12e791c0002cf9b;hb=079e0d896e1a12e3e7f08b6b09dfe2697d2feb0c;hp=352c4c586e7506a218bcc9e7f9cb6332c1cd72c7;hpb=ee21aa47a00c19068c21d631fda6598a6e0648e9;p=sage.d.git diff --git a/mjo/octonions.py b/mjo/octonions.py index 352c4c5..a5f6dec 100644 --- a/mjo/octonions.py +++ b/mjo/octonions.py @@ -345,7 +345,7 @@ class OctonionMatrix(IndexedFreeModuleElement): ncols = nrows @cached_method - def to_list(self): + def to_nested_list(self): r""" SETUP:: @@ -372,7 +372,7 @@ class OctonionMatrix(IndexedFreeModuleElement): +----+---+---+ | 0 | 0 | 0 | +----+---+---+ - sage: (E00e0 + 2*E00e3).to_list() + sage: (E00e0 + 2*E00e3).to_nested_list() [[e0 + 2*e3, 0, 0], [0, 0, 0], [0, 0, 0]] """ @@ -401,7 +401,7 @@ class OctonionMatrix(IndexedFreeModuleElement): +----+----+----+ """ - return table(self.to_list(), frame=True)._repr_() + return table(self.to_nested_list(), frame=True)._repr_() def __getitem__(self, indices): @@ -426,7 +426,7 @@ class OctonionMatrix(IndexedFreeModuleElement): """ i,j = indices - return self.to_list()[i][j] + return self.to_nested_list()[i][j] def trace(self): r""" @@ -445,6 +445,41 @@ class OctonionMatrix(IndexedFreeModuleElement): zero = self.parent().octonions().zero() return sum( (self[i,i] for i in range(self.nrows())), zero ) + def matrix_space(self): + r""" + + SETUP:: + + sage: from mjo.octonions import OctonionMatrixAlgebra + + TESTS:: + + sage: set_random_seed() + sage: MS = OctonionMatrixAlgebra(2) + sage: MS.random_element().matrix_space() + Module of 2 by 2 matrices with octonion entries over the + scalar ring Algebraic Real Field + + """ + return self.parent() + + def is_hermitian(self): + r""" + + SETUP:: + + sage: from mjo.octonions import OctonionMatrixAlgebra + + EXAMPLES:: + + sage: MS = OctonionMatrixAlgebra(3) + sage: MS.one().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 OctonionMatrixAlgebra(CombinatorialFreeModule): r""" @@ -483,6 +518,11 @@ class OctonionMatrixAlgebra(CombinatorialFreeModule): 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): r""" Return the Octonion algebra that our elements' entries come from.