From 47bf2e62cdeaaff94290310624f38c0c4eef9ccb Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 23 Aug 2019 11:52:46 -0400 Subject: [PATCH] eja: move the max test case sizes into their respective classes. --- mjo/eja/eja_algebra.py | 48 ++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 88ceef4..1337cc1 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -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) -- 2.43.2