]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: factor a few things out of the FDEJA constructor.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 12 Mar 2021 20:16:54 +0000 (15:16 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 12 Mar 2021 20:16:54 +0000 (15:16 -0500)
mjo/eja/TODO
mjo/eja/eja_algebra.py

index 9edb3790ca89f859627c43e59db540b716fe5f16..6223bff9331ba3144cbfdd8fbdd8fe616139a230 100644 (file)
@@ -13,5 +13,3 @@
 5. In CartesianProductEJA we already know the multiplication table and
    inner product matrix. Refactor things until it's no longer
    necessary to duplicate that work.
-
-6. Figure out how to remove Unital() from subalgebras.
index e26146ec81b5a0f922c27cca487aed9277ceb7e1..79187594472d82e24a0b700305b7ddfc7b192536 100644 (file)
@@ -170,6 +170,17 @@ from mjo.eja.eja_element import FiniteDimensionalEJAElement
 from mjo.eja.eja_operator import FiniteDimensionalEJAOperator
 from mjo.eja.eja_utils import _all2list, _mat2vec
 
+def EuclideanJordanAlgebras(field):
+    r"""
+    The category of Euclidean Jordan algebras over ``field``, which
+    must be a subfield of the real numbers. For now this is just a
+    convenient wrapper around all of the other category axioms that
+    apply to all EJAs.
+    """
+    category = MagmaticAlgebras(field).FiniteDimensional()
+    category = category.WithBasis().Unital().Commutative()
+    return category
+
 class FiniteDimensionalEJA(CombinatorialFreeModule):
     r"""
     A finite-dimensional Euclidean Jordan algebra.
@@ -228,6 +239,26 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
     """
     Element = FiniteDimensionalEJAElement
 
+    @staticmethod
+    def _check_input_field(field):
+        if not field.is_subring(RR):
+            # Note: this does return true for the real algebraic
+            # field, the rationals, and any quadratic field where
+            # we've specified a real embedding.
+            raise ValueError("scalar field is not real")
+
+    @staticmethod
+    def _check_input_axioms(basis, jordan_product, inner_product):
+        if not all( jordan_product(bi,bj) == jordan_product(bj,bi)
+                    for bi in basis
+                    for bj in basis ):
+            raise ValueError("Jordan product is not commutative")
+
+        if not all( inner_product(bi,bj) == inner_product(bj,bi)
+                    for bi in basis
+                    for bj in basis ):
+            raise ValueError("inner-product is not commutative")
+
     def __init__(self,
                  basis,
                  jordan_product,
@@ -244,30 +275,14 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
         n = len(basis)
 
         if check_field:
-            if not field.is_subring(RR):
-                # Note: this does return true for the real algebraic
-                # field, the rationals, and any quadratic field where
-                # we've specified a real embedding.
-                raise ValueError("scalar field is not real")
+            self._check_input_field(field)
 
         if check_axioms:
             # Check commutativity of the Jordan and inner-products.
             # This has to be done before we build the multiplication
             # and inner-product tables/matrices, because we take
             # advantage of symmetry in the process.
-            if not all( jordan_product(bi,bj) == jordan_product(bj,bi)
-                        for bi in basis
-                        for bj in basis ):
-                raise ValueError("Jordan product is not commutative")
-
-            if not all( inner_product(bi,bj) == inner_product(bj,bi)
-                        for bi in basis
-                        for bj in basis ):
-                raise ValueError("inner-product is not commutative")
-
-
-        category = MagmaticAlgebras(field).FiniteDimensional()
-        category = category.WithBasis().Unital().Commutative()
+            self._check_input_axioms(basis, jordan_product, inner_product)
 
         if n <= 1:
             # All zero- and one-dimensional algebras are just the real
@@ -286,6 +301,8 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
                                for bj in basis
                                for bk in basis)
 
+        category = EuclideanJordanAlgebras(field)
+
         if associative:
             # Element subalgebras can take advantage of this.
             category = category.Associative()