From 3e46389a46db107db3fe36ace6fe5f2c2b52f815 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 9 Nov 2020 20:59:33 -0500 Subject: [PATCH] eja: split "check" args into check_field and check_axioms. --- mjo/eja/TODO | 12 +++--- mjo/eja/eja_algebra.py | 64 ++++++++++++++++--------------- mjo/eja/eja_element_subalgebra.py | 2 +- mjo/eja/eja_subalgebra.py | 5 ++- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/mjo/eja/TODO b/mjo/eja/TODO index 0c3bd15..e8a2a8d 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -1,15 +1,13 @@ 1. Add CartesianProductEJA. -2. Check the axioms in the constructor when check != False? +2. Add references and start citing them. -3. Add references and start citing them. +3. Implement the octonion simple EJA. -4. Implement the octonion simple EJA. - -5. Factor out the unit-norm basis (and operator symmetry) tests once +4. Factor out the unit-norm basis (and operator symmetry) tests once all of the algebras pass. -6. Override inner_product(), _max_test_case_size(), et cetera in +5. Override inner_product(), _max_test_case_size(), et cetera in DirectSumEJA. -7. Switch to QQ in *all* algebras for _charpoly_coefficients(). +6. Switch to QQ in *all* algebras for _charpoly_coefficients(). diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 4bef201..26fe192 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -57,7 +57,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): prefix='e', category=None, natural_basis=None, - check=True): + check_field=True, + check_axioms=True): """ SETUP:: @@ -78,14 +79,14 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): TESTS: - The ``field`` we're given must be real with ``check=True``:: + The ``field`` we're given must be real with ``check_field=True``:: sage: JordanSpinEJA(2,QQbar) Traceback (most recent call last): ... - ValueError: field is not real + ValueError: scalar field is not real - The multiplication table must be square with ``check=True``:: + The multiplication table must be square with ``check_axioms=True``:: sage: FiniteDimensionalEuclideanJordanAlgebra(QQ,((),())) Traceback (most recent call last): @@ -93,12 +94,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): ValueError: multiplication table is not square """ - if check: + if check_field: 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') + # field, the rationals, and any quadratic field where + # we've specified a real embedding. + raise ValueError("scalar field is not real") + + # The multiplication table had better be square + n = len(mult_table) + if check_axioms: + if not all( len(l) == n for l in mult_table ): + raise ValueError("multiplication table is not square") self._natural_basis = natural_basis @@ -106,12 +113,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): category = MagmaticAlgebras(field).FiniteDimensional() category = category.WithBasis().Unital() - # The multiplication table had better be square - n = len(mult_table) - if check: - if not all( len(l) == n for l in mult_table ): - raise ValueError("multiplication table is not square") - fda = super(FiniteDimensionalEuclideanJordanAlgebra, self) fda.__init__(field, range(n), @@ -130,7 +131,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): for ls in mult_table ] - if check: + if check_axioms: if not self._is_commutative(): raise ValueError("algebra is not commutative") if not self._is_jordanian(): @@ -263,8 +264,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): Whether or not this algebra's multiplication table is commutative. This method should of course always return ``True``, unless - this algebra was constructed with ``check=False`` and passed - an invalid multiplication table. + this algebra was constructed with ``check_axioms=False`` and + passed an invalid multiplication table. """ return all( self.product_on_basis(i,j) == self.product_on_basis(i,j) for i in range(self.dimension()) @@ -279,7 +280,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): ``True`` result to be truly true, you should also check :meth:`_is_commutative`. This method should of course always return ``True``, unless this algebra was constructed with - ``check=False`` and passed an invalid multiplication table. + ``check_axioms=False`` and passed an invalid multiplication table. """ return all( (self.monomial(i)**2)*(self.monomial(i)*self.monomial(j)) == @@ -293,13 +294,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): associative; that is, whether or not `B(xy,z) = B(x,yz)`. This method should of course always return ``True``, unless - this algebra was constructed with ``check=False`` and passed - an invalid multiplication table. + this algebra was constructed with ``check_axioms=False`` and + passed an invalid multiplication table. """ # Used to check whether or not something is zero in an inexact # ring. This number is sufficient to allow the construction of - # QuaternionHermitianEJA(2, RDF) with check=True. + # QuaternionHermitianEJA(2, RDF) with check_axioms=True. epsilon = 1e-16 for i in range(self.dimension()): @@ -747,7 +748,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): gens = tuple( self.from_vector(b) for b in eigspace.basis() ) subalg = FiniteDimensionalEuclideanJordanSubalgebra(self, gens, - check=False) + check_axioms=False) if eigval == 0: J0 = subalg elif eigval == 1: @@ -1053,7 +1054,7 @@ class HadamardEJA(FiniteDimensionalEuclideanJordanAlgebra): super(HadamardEJA, self).__init__(field, mult_table, - check=False, + check_axioms=False, **kwargs) self.rank.set_cache(n) @@ -1165,13 +1166,14 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra): # Do this over the rationals and convert back at the end. # Only works because we know the entries of the basis are - # integers. The argument ``check=False`` is required + # integers. The argument ``check_axioms=False`` is required # because the trace inner-product method for this # class is a stub and can't actually be checked. J = MatrixEuclideanJordanAlgebra(QQ, basis, normalize_basis=False, - check=False) + check_field=False, + check_axioms=False) a = J._charpoly_coefficients() # Unfortunately, changing the basis does change the @@ -1411,7 +1413,7 @@ class RealSymmetricEJA(RealMatrixEuclideanJordanAlgebra): basis = self._denormalized_basis(n, field) super(RealSymmetricEJA, self).__init__(field, basis, - check=False, + check_axioms=False, **kwargs) self.rank.set_cache(n) @@ -1710,7 +1712,7 @@ class ComplexHermitianEJA(ComplexMatrixEuclideanJordanAlgebra): basis = self._denormalized_basis(n,field) super(ComplexHermitianEJA,self).__init__(field, basis, - check=False, + check_axioms=False, **kwargs) self.rank.set_cache(n) @@ -2014,7 +2016,7 @@ class QuaternionHermitianEJA(QuaternionMatrixEuclideanJordanAlgebra): basis = self._denormalized_basis(n,field) super(QuaternionHermitianEJA,self).__init__(field, basis, - check=False, + check_axioms=False, **kwargs) self.rank.set_cache(n) @@ -2100,7 +2102,7 @@ class BilinearFormEJA(FiniteDimensionalEuclideanJordanAlgebra): # by the ambient dimension). super(BilinearFormEJA, self).__init__(field, mult_table, - check=False, + check_axioms=False, **kwargs) self.rank.set_cache(min(n,2)) @@ -2229,7 +2231,7 @@ class TrivialEJA(FiniteDimensionalEuclideanJordanAlgebra): mult_table = [] super(TrivialEJA, self).__init__(field, mult_table, - check=False, + check_axioms=False, **kwargs) # The rank is zero using my definition, namely the dimension of the # largest subalgebra generated by any element. @@ -2280,6 +2282,6 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra): super(DirectSumEJA, self).__init__(field, mult_table, - check=False, + check_axioms=False, **kwargs) self.rank.set_cache(J1.rank() + J2.rank()) diff --git a/mjo/eja/eja_element_subalgebra.py b/mjo/eja/eja_element_subalgebra.py index a4d7d1f..b9069c4 100644 --- a/mjo/eja/eja_element_subalgebra.py +++ b/mjo/eja/eja_element_subalgebra.py @@ -53,7 +53,7 @@ class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclide fdeja.__init__(self._superalgebra, superalgebra_basis, category=category, - check=False) + check_axioms=False) # The rank is the highest possible degree of a minimal # polynomial, and is bounded above by the dimension. We know diff --git a/mjo/eja/eja_subalgebra.py b/mjo/eja/eja_subalgebra.py index d7bcf2c..8f00373 100644 --- a/mjo/eja/eja_subalgebra.py +++ b/mjo/eja/eja_subalgebra.py @@ -130,7 +130,7 @@ class FiniteDimensionalEuclideanJordanSubalgebra(FiniteDimensionalEuclideanJorda 1 """ - def __init__(self, superalgebra, basis, category=None, check=True): + def __init__(self, superalgebra, basis, category=None, check_axioms=True): self._superalgebra = superalgebra V = self._superalgebra.vector_space() field = self._superalgebra.base_ring() @@ -180,7 +180,8 @@ class FiniteDimensionalEuclideanJordanSubalgebra(FiniteDimensionalEuclideanJorda prefix=prefix, category=category, natural_basis=natural_basis, - check=check) + check_field=False, + check_axioms=check_axioms) -- 2.44.2