]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: move the max test case sizes into their respective classes.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 23 Aug 2019 15:52:46 +0000 (11:52 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 23 Aug 2019 15:52:46 +0000 (11:52 -0400)
mjo/eja/eja_algebra.py

index 88ceef48a370e21ea10b7afca34057c048579f2d..1337cc14f8a82862cca9a3eb069a6e33b9c397f2 100644 (file)
@@ -155,6 +155,26 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         return self.from_vector(coords)
 
 
+    @staticmethod
+    def _max_test_case_size():
+        """
+        Return an integer "size" that is an upper bound on the size of
+        this algebra when it is used in a random test
+        case. Unfortunately, the term "size" is quite vague -- when
+        dealing with `R^n` under either the Hadamard or Jordan spin
+        product, the "size" refers to the dimension `n`. When dealing
+        with a matrix algebra (real symmetric or complex/quaternion
+        Hermitian), it refers to the size of the matrix, which is
+        far less than the dimension of the underlying vector space.
+
+        We default to five in this class, which is safe in `R^n`. The
+        matrix algebra subclasses (or any class where the "size" is
+        interpreted to be far less than the dimension) should override
+        with a smaller number.
+        """
+        return 5
+
+
     def _repr_(self):
         """
         Return a string representation of ``self``.
@@ -841,17 +861,12 @@ def random_eja():
         Euclidean Jordan algebra of dimension...
 
     """
-
-    # The max_n component lets us choose different upper bounds on the
-    # value "n" that gets passed to the constructor. This is needed
-    # because e.g. R^{10} is reasonable to test, while the Hermitian
-    # 10-by-10 quaternion matrices are not.
-    (constructor, max_n) = choice([(RealCartesianProductEJA, 6),
-                                   (JordanSpinEJA, 6),
-                                   (RealSymmetricEJA, 5),
-                                   (ComplexHermitianEJA, 4),
-                                   (QuaternionHermitianEJA, 3)])
-    n = ZZ.random_element(1, max_n)
+    constructor = choice([RealCartesianProductEJA,
+                          JordanSpinEJA,
+                          RealSymmetricEJA,
+                          ComplexHermitianEJA,
+                          QuaternionHermitianEJA])
+    n = ZZ.random_element(1, constructor._max_test_case_size())
     return constructor(n, field=QQ)
 
 
@@ -1378,6 +1393,9 @@ class RealSymmetricEJA(FiniteDimensionalEuclideanJordanAlgebra):
                               natural_basis=S,
                               **kwargs)
 
+    @staticmethod
+    def _max_test_case_size():
+        return 5
 
 
 class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra):
@@ -1482,6 +1500,10 @@ class ComplexHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra):
                               **kwargs)
 
 
+    @staticmethod
+    def _max_test_case_size():
+        return 4
+
     @staticmethod
     def natural_inner_product(X,Y):
         Xu = _unembed_complex_matrix(X)
@@ -1592,6 +1614,10 @@ class QuaternionHermitianEJA(FiniteDimensionalEuclideanJordanAlgebra):
                               natural_basis=S,
                               **kwargs)
 
+    @staticmethod
+    def _max_test_case_size():
+        return 3
+
     @staticmethod
     def natural_inner_product(X,Y):
         Xu = _unembed_quaternion_matrix(X)