X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=a0af3f0ef543dd951b2463a8aef0f295a2561287;hb=efe6cd067e02b788bfcdc5e8b61e994cd524120c;hp=21718ee85e168d9ead63b061a3d623cb3ab6c8cc;hpb=f7084ccf4fcf16c3f457f192d63a35f6ff5c1cbc;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 21718ee..a0af3f0 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -24,15 +24,12 @@ from sage.combinat.free_module import CombinatorialFreeModule from sage.matrix.constructor import matrix from sage.matrix.matrix_space import MatrixSpace from sage.misc.cachefunc import cached_method -from sage.misc.lazy_import import lazy_import from sage.misc.table import table from sage.modules.free_module import FreeModule, VectorSpace from sage.rings.all import (ZZ, QQ, AA, QQbar, RR, RLF, CLF, PolynomialRing, QuadraticField) from mjo.eja.eja_element import FiniteDimensionalEuclideanJordanAlgebraElement -lazy_import('mjo.eja.eja_subalgebra', - 'FiniteDimensionalEuclideanJordanSubalgebra') from mjo.eja.eja_operator import FiniteDimensionalEuclideanJordanAlgebraOperator from mjo.eja.eja_utils import _mat2vec @@ -57,7 +54,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): sage: J(1) Traceback (most recent call last): ... - ValueError: not a naturally-represented algebra element + ValueError: not an element of this algebra """ return None @@ -180,7 +177,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): sage: J(A) Traceback (most recent call last): ... - ArithmeticError: vector is not in free module + ValueError: not an element of this algebra TESTS: @@ -199,7 +196,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): True """ - msg = "not a naturally-represented algebra element" + msg = "not an element of this algebra" if elt == 0: # The superclass implementation of random_element() # needs to be able to coerce "0" into the algebra. @@ -224,7 +221,12 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): # could be QQ instead of QQbar. V = VectorSpace(basis_space.base_ring(), elt.nrows()*elt.ncols()) W = V.span_of_basis( _mat2vec(s) for s in natural_basis ) - coords = W.coordinate_vector(_mat2vec(elt)) + + try: + coords = W.coordinate_vector(_mat2vec(elt)) + except ArithmeticError: # vector is not in free module + raise ValueError(msg) + return self.from_vector(coords) def _repr_(self): @@ -768,6 +770,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): if not c.is_idempotent(): raise ValueError("element is not idempotent: %s" % c) + from mjo.eja.eja_subalgebra import FiniteDimensionalEuclideanJordanSubalgebra + # Default these to what they should be if they turn out to be # trivial, because eigenspaces_left() won't return eigenvalues # corresponding to trivial spaces (e.g. it returns only the