X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_utils.py;fp=mjo%2Feja%2Feja_utils.py;h=6f8cab6d8019dcbba0be1e81c3872a7ba738f807;hb=a46720db62543983ab375654dee211ca844ac46c;hp=0b2d2a315989949c2431641c8f82dea9b576f9b8;hpb=e28bd3518185e3a87866c61d973876f84fdeea66;p=sage.d.git diff --git a/mjo/eja/eja_utils.py b/mjo/eja/eja_utils.py index 0b2d2a3..6f8cab6 100644 --- a/mjo/eja/eja_utils.py +++ b/mjo/eja/eja_utils.py @@ -54,7 +54,9 @@ def _all2list(x): SETUP:: sage: from mjo.eja.eja_utils import _all2list - sage: from mjo.octonions import Octonions, OctonionMatrixAlgebra + sage: from mjo.hurwitz import (QuaternionMatrixAlgebra, + ....: Octonions, + ....: OctonionMatrixAlgebra) EXAMPLES:: @@ -86,6 +88,13 @@ def _all2list(x): sage: _all2list(OctonionMatrixAlgebra(1).one()) [1, 0, 0, 0, 0, 0, 0, 0] + :: + + sage: _all2list(QuaternionAlgebra(QQ, -1, -1).one()) + [1, 0, 0, 0] + sage: _all2list(QuaternionMatrixAlgebra(1).one()) + [1, 0, 0, 0] + :: sage: V1 = VectorSpace(QQ,2) @@ -97,6 +106,13 @@ def _all2list(x): [3, 4, 1, 0, 0, 0, 0, 0, 0, 0] """ + if hasattr(x, 'list') and hasattr(x, 'to_vector'): + # This avoids calling to_vector() on a matrix algebra with + # e.g. quaternions where the returned vector is of the wrong + # length (three instead of four) because the quaternions don't + # know how many generators they have. + return _all2list(x.list()) + if hasattr(x, 'to_vector'): # This works on matrices of e.g. octonions directly, without # first needing to convert them to a list of octonions and