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::
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)
[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