- sage: set_random_seed()
- sage: n = ZZ.random_element(2)
- sage: Q = QuaternionAlgebra(QQ,-1,-1)
- sage: X = random_matrix(Q, n)
- sage: Y = random_matrix(Q, n)
- sage: Xe = QuaternionMatrixEJA.real_embed(X)
- sage: Ye = QuaternionMatrixEJA.real_embed(Y)
- sage: XYe = QuaternionMatrixEJA.real_embed(X*Y)
- sage: Xe*Ye == XYe
- True
-
- """
- super(QuaternionMatrixEJA,cls).real_embed(M)
- quaternions = M.base_ring()
- n = M.nrows()
-
- F = QuadraticField(-1, 'I')
- i = F.gen()
-
- blocks = []
- for z in M.list():
- t = z.coefficient_tuple()
- a = t[0]
- b = t[1]
- c = t[2]
- d = t[3]
- cplxM = matrix(F, 2, [[ a + b*i, c + d*i],
- [-c + d*i, a - b*i]])
- realM = ComplexMatrixEJA.real_embed(cplxM)
- blocks.append(realM)
-
- # We should have real entries by now, so use the realest field
- # we've got for the return value.
- return matrix.block(quaternions.base_ring(), n, blocks)
-
-
-
- @classmethod
- def real_unembed(cls,M):
- """
- The inverse of _embed_quaternion_matrix().
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import QuaternionMatrixEJA
-
- EXAMPLES::
-
- sage: M = matrix(QQ, [[ 1, 2, 3, 4],
- ....: [-2, 1, -4, 3],
- ....: [-3, 4, 1, -2],
- ....: [-4, -3, 2, 1]])
- sage: QuaternionMatrixEJA.real_unembed(M)
- [1 + 2*i + 3*j + 4*k]
-
- TESTS:
-
- Unembedding is the inverse of embedding::
-
- sage: set_random_seed()
- sage: Q = QuaternionAlgebra(QQ, -1, -1)
- sage: M = random_matrix(Q, 3)
- sage: Me = QuaternionMatrixEJA.real_embed(M)
- sage: QuaternionMatrixEJA.real_unembed(Me) == M
- True
-
- """
- super(QuaternionMatrixEJA,cls).real_unembed(M)
- n = ZZ(M.nrows())
- d = cls.dimension_over_reals()
-
- # Use the base ring of the matrix to ensure that its entries can be
- # multiplied by elements of the quaternion algebra.
- Q = cls.quaternion_extension(M.base_ring())
- i,j,k = Q.gens()
-
- # Go top-left to bottom-right (reading order), converting every
- # 4-by-4 block we see to a 2-by-2 complex block, to a 1-by-1
- # quaternion block.
- elements = []
- for l in range(n/d):
- for m in range(n/d):
- submat = ComplexMatrixEJA.real_unembed(
- M[d*l:d*l+d,d*m:d*m+d] )
- if submat[0,0] != submat[1,1].conjugate():
- raise ValueError('bad on-diagonal submatrix')
- if submat[0,1] != -submat[1,0].conjugate():
- raise ValueError('bad off-diagonal submatrix')
- z = submat[0,0].real()
- z += submat[0,0].imag()*i
- z += submat[0,1].real()*j
- z += submat[0,1].imag()*k
- elements.append(z)
-
- return matrix(Q, n/d, elements)
-
-
-class QuaternionHermitianEJA(ConcreteEJA, QuaternionMatrixEJA):
- r"""
- The rank-n simple EJA consisting of self-adjoint n-by-n quaternion
- matrices, the usual symmetric Jordan product, and the
- real-part-of-trace inner product. It has dimension `2n^2 - n` over
- the reals.
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import QuaternionHermitianEJA
-
- EXAMPLES:
-
- In theory, our "field" can be any subfield of the reals::
-
- sage: QuaternionHermitianEJA(2, field=RDF)
- Euclidean Jordan algebra of dimension 6 over Real Double Field
- sage: QuaternionHermitianEJA(2, field=RR)
- Euclidean Jordan algebra of dimension 6 over Real Field with
- 53 bits of precision
-
- TESTS:
-
- The dimension of this algebra is `2*n^2 - n`::
-
- sage: set_random_seed()
- sage: n_max = QuaternionHermitianEJA._max_random_instance_size()
- sage: n = ZZ.random_element(1, n_max)
- sage: J = QuaternionHermitianEJA(n)
- sage: J.dimension() == 2*(n^2) - n
- True
-
- The Jordan multiplication is what we think it is::