X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=a2adbb2bed47499aea53b38fe175547b887fb2a9;hb=e6bb7aba7677a04c3aaa4d1fdd9dd45185db2067;hp=4ee5aba352bf870b679e8c782559c53e2db579ad;hpb=ebb0595a1c30afe9690d081672d8dfc88e90af74;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 4ee5aba..a2adbb2 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -1746,7 +1746,7 @@ class ConcreteEJA(FiniteDimensionalEJA): return eja_class.random_instance(*args, **kwargs) -class MatrixEJA: +class MatrixEJA(FiniteDimensionalEJA): @staticmethod def _denormalized_basis(A): """ @@ -1887,8 +1887,23 @@ class MatrixEJA: return tr.real() + def __init__(self, matrix_space, **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().__init__(self._denormalized_basis(matrix_space), + self.jordan_product, + self.trace_inner_product, + field=matrix_space.base_ring(), + matrix_space=matrix_space, + **kwargs) + + self.rank.set_cache(matrix_space.nrows()) + self.one.set_cache( self(matrix_space.one()) ) -class RealSymmetricEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): +class RealSymmetricEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA): """ The rank-n simple EJA consisting of real symmetric n-by-n matrices, the usual symmetric Jordan product, and the trace inner @@ -1971,22 +1986,19 @@ class RealSymmetricEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): if "check_axioms" not in kwargs: kwargs["check_axioms"] = False A = MatrixSpace(field, n) - super().__init__(self._denormalized_basis(A), - self.jordan_product, - self.trace_inner_product, - field=field, - matrix_space=A, - **kwargs) + super().__init__(A, **kwargs) - # TODO: this could be factored out somehow, but is left here - # because the MatrixEJA is not presently a subclass of the - # FDEJA class that defines rank() and one(). - self.rank.set_cache(n) - self.one.set_cache( self(A.one()) ) + from mjo.eja.eja_cache import real_symmetric_eja_coeffs + a = real_symmetric_eja_coeffs(self) + if a is not None: + if self._rational_algebra is None: + self._charpoly_coefficients.set_cache(a) + else: + self._rational_algebra._charpoly_coefficients.set_cache(a) -class ComplexHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): +class ComplexHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA): """ The rank-n simple EJA consisting of complex Hermitian n-by-n matrices over the real numbers, the usual symmetric Jordan product, @@ -2064,19 +2076,15 @@ class ComplexHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): from mjo.hurwitz import ComplexMatrixAlgebra A = ComplexMatrixAlgebra(n, scalars=field) - super().__init__(self._denormalized_basis(A), - self.jordan_product, - self.trace_inner_product, - field=field, - matrix_space=A, - **kwargs) - - # TODO: this could be factored out somehow, but is left here - # because the MatrixEJA is not presently a subclass of the - # FDEJA class that defines rank() and one(). - self.rank.set_cache(n) - self.one.set_cache( self(A.one()) ) + super().__init__(A, **kwargs) + from mjo.eja.eja_cache import complex_hermitian_eja_coeffs + a = complex_hermitian_eja_coeffs(self) + if a is not None: + if self._rational_algebra is None: + self._charpoly_coefficients.set_cache(a) + else: + self._rational_algebra._charpoly_coefficients.set_cache(a) @staticmethod def _max_random_instance_size(): @@ -2091,7 +2099,7 @@ class ComplexHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): return cls(n, **kwargs) -class QuaternionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): +class QuaternionHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA): r""" The rank-n simple EJA consisting of self-adjoint n-by-n quaternion matrices, the usual symmetric Jordan product, and the @@ -2155,18 +2163,16 @@ class QuaternionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): from mjo.hurwitz import QuaternionMatrixAlgebra A = QuaternionMatrixAlgebra(n, scalars=field) - super().__init__(self._denormalized_basis(A), - self.jordan_product, - self.trace_inner_product, - field=field, - matrix_space=A, - **kwargs) + super().__init__(A, **kwargs) + + from mjo.eja.eja_cache import quaternion_hermitian_eja_coeffs + a = quaternion_hermitian_eja_coeffs(self) + if a is not None: + if self._rational_algebra is None: + self._charpoly_coefficients.set_cache(a) + else: + self._rational_algebra._charpoly_coefficients.set_cache(a) - # TODO: this could be factored out somehow, but is left here - # because the MatrixEJA is not presently a subclass of the - # FDEJA class that defines rank() and one(). - self.rank.set_cache(n) - self.one.set_cache( self(A.one()) ) @staticmethod @@ -2184,7 +2190,7 @@ class QuaternionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): n = ZZ.random_element(cls._max_random_instance_size() + 1) return cls(n, **kwargs) -class OctonionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): +class OctonionHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA): r""" SETUP:: @@ -2297,18 +2303,15 @@ class OctonionHermitianEJA(RationalBasisEJA, ConcreteEJA, MatrixEJA): from mjo.hurwitz import OctonionMatrixAlgebra A = OctonionMatrixAlgebra(n, scalars=field) - super().__init__(self._denormalized_basis(A), - self.jordan_product, - self.trace_inner_product, - field=field, - matrix_space=A, - **kwargs) + super().__init__(A, **kwargs) - # TODO: this could be factored out somehow, but is left here - # because the MatrixEJA is not presently a subclass of the - # FDEJA class that defines rank() and one(). - self.rank.set_cache(n) - self.one.set_cache( self(A.one()) ) + from mjo.eja.eja_cache import octonion_hermitian_eja_coeffs + a = octonion_hermitian_eja_coeffs(self) + if a is not None: + if self._rational_algebra is None: + self._charpoly_coefficients.set_cache(a) + else: + self._rational_algebra._charpoly_coefficients.set_cache(a) class AlbertEJA(OctonionHermitianEJA):