From e224054da4441a27efe2301ce18e688f17408ddb Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 3 Dec 2020 12:39:49 -0500 Subject: [PATCH] eja: disable axiom checking for concrete algebras. --- mjo/eja/TODO | 3 --- mjo/eja/eja_algebra.py | 44 ++++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/mjo/eja/TODO b/mjo/eja/TODO index b298e69..9f80537 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -20,6 +20,3 @@ sage: a0 = (1/4)*X[4]**2*X[6]**2 - (1/2)*X[2]*X[5]*X[6]**2 - (1/2)*X[3]*X[4]*X[6 6. The main EJA element constructor is happy to convert between e.g. HadamardEJA(3) and JordanSpinEJA(3). - -8. Add back the check_field=False and check_axioms=False parameters - for the EJAs we've constructed ourselves. diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index e32bc24..e075ed2 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -1631,6 +1631,10 @@ class RealSymmetricEJA(ConcreteEuclideanJordanAlgebra, return cls(n, **kwargs) def __init__(self, n, **kwargs): + # We know this is a valid EJA, but will double-check + # if the user passes check_axioms=True. + if "check_axioms" not in kwargs: kwargs["check_axioms"] = False + super(RealSymmetricEJA, self).__init__(self._denormalized_basis(n), self.jordan_product, self.trace_inner_product, @@ -1912,6 +1916,10 @@ class ComplexHermitianEJA(ConcreteEuclideanJordanAlgebra, def __init__(self, n, **kwargs): + # We know this is a valid EJA, but will double-check + # if the user passes check_axioms=True. + if "check_axioms" not in kwargs: kwargs["check_axioms"] = False + super(ComplexHermitianEJA, self).__init__(self._denormalized_basis(n), self.jordan_product, self.trace_inner_product, @@ -2209,6 +2217,10 @@ class QuaternionHermitianEJA(ConcreteEuclideanJordanAlgebra, def __init__(self, n, **kwargs): + # We know this is a valid EJA, but will double-check + # if the user passes check_axioms=True. + if "check_axioms" not in kwargs: kwargs["check_axioms"] = False + super(QuaternionHermitianEJA, self).__init__(self._denormalized_basis(n), self.jordan_product, self.trace_inner_product, @@ -2279,18 +2291,20 @@ class HadamardEJA(ConcreteEuclideanJordanAlgebra): def inner_product(x,y): return x.inner_product(y) - # Don't orthonormalize because our basis is already - # orthonormal with respect to our inner-product. - if not 'orthonormalize' in kwargs: - kwargs['orthonormalize'] = False + # New defaults for keyword arguments. Don't orthonormalize + # because our basis is already orthonormal with respect to our + # inner-product. Don't check the axioms, because we know this + # is a valid EJA... but do double-check if the user passes + # check_axioms=True. Note: we DON'T override the "check_field" + # default here, because the user can pass in a field! + if "orthonormalize" not in kwargs: kwargs["orthonormalize"] = False + if "check_axioms" not in kwargs: kwargs["check_axioms"] = False + - # But also don't pass check_field=False here, because the user - # can pass in a field! standard_basis = FreeModule(ZZ, n).basis() super(HadamardEJA, self).__init__(standard_basis, jordan_product, inner_product, - check_axioms=False, **kwargs) self.rank.set_cache(n) @@ -2413,6 +2427,10 @@ class BilinearFormEJA(ConcreteEuclideanJordanAlgebra): zbar = y0*xbar + x0*ybar return P((z0,) + tuple(zbar)) + # We know this is a valid EJA, but will double-check + # if the user passes check_axioms=True. + if "check_axioms" not in kwargs: kwargs["check_axioms"] = False + n = B.nrows() standard_basis = FreeModule(ZZ, n).basis() super(BilinearFormEJA, self).__init__(standard_basis, @@ -2519,14 +2537,11 @@ class JordanSpinEJA(BilinearFormEJA): # Don't orthonormalize because our basis is already # orthonormal with respect to our inner-product. - if not 'orthonormalize' in kwargs: - kwargs['orthonormalize'] = False + if "orthonormalize" not in kwargs: kwargs["orthonormalize"] = False # But also don't pass check_field=False here, because the user # can pass in a field! - super(JordanSpinEJA, self).__init__(B, - check_axioms=False, - **kwargs) + super(JordanSpinEJA, self).__init__(B, **kwargs) @staticmethod def _max_random_instance_size(): @@ -2579,6 +2594,11 @@ class TrivialEJA(ConcreteEuclideanJordanAlgebra): jordan_product = lambda x,y: x inner_product = lambda x,y: 0 basis = () + + # New defaults for keyword arguments + if "orthonormalize" not in kwargs: kwargs["orthonormalize"] = False + if "check_axioms" not in kwargs: kwargs["check_axioms"] = False + super(TrivialEJA, self).__init__(basis, jordan_product, inner_product, -- 2.44.2