]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add "check" parameter to check if our field is real.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Aug 2019 00:32:55 +0000 (20:32 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Aug 2019 00:32:55 +0000 (20:32 -0400)
mjo/eja/TODO
mjo/eja/eja_algebra.py

index 51c2a33b542569c431d986a0d165d8774b0d49eb..b2495b59f3264e5d638a59f6630daa77214cdb50 100644 (file)
@@ -17,5 +17,3 @@
 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.
index 430f233114b09f36361322e5f2d4b4e408fd2aeb..7a65fabdcfcd4adf9c2369dd7d64da50e17b1bd3 100644 (file)
@@ -16,12 +16,9 @@ from sage.misc.cachefunc import cached_method
 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
 
@@ -40,11 +37,12 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
                  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:
 
@@ -56,7 +54,23 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             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