X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Foctonions.py;h=c2b829f98b9b49dbe078172a3669f0cb8b6406e4;hb=ff8c9b19da5ed821366a491a95b4f6c946f315ae;hp=87bf5ff1ed06b1a77b5815df8dd2248fda4b7edb;hpb=9ffb2ed473d62df9f6b6db9636b0bf8fa8f3be25;p=sage.d.git diff --git a/mjo/octonions.py b/mjo/octonions.py index 87bf5ff..c2b829f 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,29 @@ class OctonionMatrix(IndexedFreeModuleElement): +----+----+----+ """ - return table(self.to_list(), frame=True)._repr_() + return table(self.to_nested_list(), frame=True)._repr_() + + + def list(self): + r""" + Return one long list of this matrix's entries. + + SETUP:: + + sage: from mjo.octonions import OctonionMatrixAlgebra + + EXAMPLES:: + + sage: MS = OctonionMatrixAlgebra(3) + sage: E00e0 = MS.gens()[0] + sage: E00e3 = MS.gens()[3] + sage: (E00e0 + 2*E00e3).to_nested_list() + [[e0 + 2*e3, 0, 0], [0, 0, 0], [0, 0, 0]] + sage: (E00e0 + 2*E00e3).list() + [e0 + 2*e3, 0, 0, 0, 0, 0, 0, 0, 0] + + """ + return sum( self.to_nested_list(), [] ) def __getitem__(self, indices): @@ -426,7 +448,7 @@ class OctonionMatrix(IndexedFreeModuleElement): """ i,j = indices - return self.to_list()[i][j] + return self.to_nested_list()[i][j] def trace(self): r"""