7. Do we really need to orthonormalize the basis in a subalgebra?
So long as we can decompose the operator (which is invariant
under changes of basis), who cares?
-
-8. Check that our field is a subring of RLF.
from sage.misc.prandom import choice
from sage.misc.table import table
from sage.modules.free_module import FreeModule, VectorSpace
-from sage.rings.integer_ring import ZZ
-from sage.rings.number_field.number_field import QuadraticField
-from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
-from sage.rings.rational_field import QQ
-from sage.rings.real_lazy import CLF, RLF
-
+from sage.rings.all import (ZZ, QQ, RR, RLF, CLF,
+ PolynomialRing,
+ QuadraticField)
from mjo.eja.eja_element import FiniteDimensionalEuclideanJordanAlgebraElement
from mjo.eja.eja_utils import _mat2vec
rank,
prefix='e',
category=None,
- natural_basis=None):
+ natural_basis=None,
+ check=True):
"""
SETUP::
- sage: from mjo.eja.eja_algebra import random_eja
+ sage: from mjo.eja.eja_algebra import (JordanSpinEJA, random_eja)
EXAMPLES:
sage: x*y == y*x
True
+ TESTS:
+
+ The ``field`` we're given must be real::
+
+ sage: JordanSpinEJA(2,QQbar)
+ Traceback (most recent call last):
+ ...
+ ValueError: field is not real
+
"""
+ if check:
+ if not field.is_subring(RR):
+ # Note: this does return true for the real algebraic
+ # field, and any quadratic field where we've specified
+ # a real embedding.
+ raise ValueError('field is not real')
+
self._rank = rank
self._natural_basis = natural_basis