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)
# 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
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.