X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=7c2eda211232ceac757a6d6caa40ae6722528349;hb=33b5476e1422a36972979e768f1829cec1b421a5;hp=3f2127d7df9b811a599ba1da01b7b100ab0a5573;hpb=d875b32c8b9063a501b4387af357bd7a9f21633e;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 3f2127d..7c2eda2 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -21,7 +21,6 @@ from sage.rings.number_field.number_field import NumberField, QuadraticField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.rational_field import QQ from sage.rings.real_lazy import CLF, RLF -from sage.structure.element import is_Matrix from mjo.eja.eja_element import FiniteDimensionalEuclideanJordanAlgebraElement from mjo.eja.eja_utils import _mat2vec @@ -406,8 +405,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): EXAMPLES: - Our inner product satisfies the Jordan axiom, which is also - referred to as "associativity" for a symmetric bilinear form:: + Our inner product is "associative," which means the following for + a symmetric bilinear form:: sage: set_random_seed() sage: J = random_eja() @@ -940,8 +939,9 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra): else: basis = ( (b/n) for (b,n) in izip(self.natural_basis(), self._basis_normalizers) ) - field = self.base_ring().base_ring() # yeeeaahhhhhhh - J = MatrixEuclideanJordanAlgebra(field, + + # Do this over the rationals and convert back at the end. + J = MatrixEuclideanJordanAlgebra(QQ, basis, self.rank(), normalize_basis=False) @@ -950,7 +950,14 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra): # p might be missing some vars, have to substitute "optionally" pairs = izip(x.base_ring().gens(), self._basis_normalizers) substitutions = { v: v*c for (v,c) in pairs } - return p.subs(substitutions) + result = p.subs(substitutions) + + # The result of "subs" can be either a coefficient-ring + # element or a polynomial. Gotta handle both cases. + if result in QQ: + return self.base_ring()(result) + else: + return result.change_ring(self.base_ring()) @staticmethod @@ -1256,7 +1263,7 @@ class ComplexMatrixEuclideanJordanAlgebra(MatrixEuclideanJordanAlgebra): if not n.mod(2).is_zero(): raise ValueError("the matrix 'M' must be a complex embedding") - field = M.base_ring() # This should already have sqrt2 + field = QQ R = PolynomialRing(field, 'z') z = R.gen() F = NumberField(z**2 + 1,'i', embedding=CLF(-1).sqrt()) @@ -1396,7 +1403,7 @@ class ComplexHermitianEJA(ComplexMatrixEuclideanJordanAlgebra, KnownRankEJA): True """ - R = PolynomialRing(field, 'z') + R = PolynomialRing(QQ, 'z') z = R.gen() F = NumberField(z**2 + 1, 'I', embedding=CLF(-1).sqrt()) I = F.gen() @@ -1533,7 +1540,7 @@ class QuaternionMatrixEuclideanJordanAlgebra(MatrixEuclideanJordanAlgebra): if M.ncols() != n: raise ValueError("the matrix 'M' must be square") if not n.mod(4).is_zero(): - raise ValueError("the matrix 'M' must be a complex embedding") + raise ValueError("the matrix 'M' must be a quaternion embedding") # Use the base ring of the matrix to ensure that its entries can be # multiplied by elements of the quaternion algebra. @@ -1705,7 +1712,10 @@ class QuaternionHermitianEJA(QuaternionMatrixEuclideanJordanAlgebra, S.append(Sij_J) Sij_K = cls.real_embed(K*Eij - K*Eij.transpose()) S.append(Sij_K) - return S + + # Since we embedded these, we can drop back to the "field" that we + # started with instead of the quaternion algebra "Q". + return ( s.change_ring(field) for s in S ) def __init__(self, n, field=QQ, **kwargs):