Matrix operations
The quaternions form a noncommutative ring, and therefore addition and multiplication can be defined for quaternionic matrices as for matrices over any ring.
Addition. The sum of two quaternionic matrices A and B is defined in the usual way by element-wise addition:

Multiplication. The product of two quaternionic matrices A and B also follows the usual definition for matrix multiplication. For it to be defined, the number of columns of A must equal the number of rows of B. Then the entry in the ith row and jth column of the product is the dot product of the ith row of the first matrix with the jth column of the second matrix. Specifically:

For example, for

the product is

Since quaternionic multiplication is noncommutative, care must be taken to preserve the order of the factors when computing the product of matrices.
The identity for this multiplication is, as expected, the diagonal matrix I = diag(1, 1, ... , 1). Multiplication follows the usual laws of associativity and distributivity. The trace of a matrix is defined as the sum of the diagonal elements, but in general

Left scalar multiplication, and right scalar multiplication are defined by

Again, since multiplication is not commutative some care must be taken in the order of the factors.
Hyperquaternionic representation
Due to the isomorphism
where
is a
real matrix, a quaternion matrix can be represented as a hypercomplex number constituted by a tensor product of quaternion algebras called hyperquaternions

where
, etc. are commuting quaternionic systems.
, etc .
Examples are:
,
.
A hyperconjugation is defined by

where
is the quaternion conjugation hence,
. In particular,
where
is the transpose quaternion conjugate of the quaternionic matrix
.
The unitary symplectic group
is the group of quaternionic matrices
such that
.
Hyperquaternions are Clifford algebras
having
generators
multipying according to
with
(
generators) and
(
generators) . One has
.
A basis of
is given by
