Can the DifferentialEquations package actually solve quaternion equations correctly? Quaternions are non-commutative and I'd hazard to guess that some solver methods would assume commutativity at some point.
function cmatrix(Q::AbstractVecOrMat{Quaternion{T}}) where {T}
[complex.( real.(Q), imag.(Q)) complex.( jmag.(Q), kmag.(Q));
complex.(-jmag.(Q), kmag.(Q)) complex.( real.(Q), -imag.(Q))]
end
function qmatrix(C::AbstractMatrix{Complex{T}}) where {T}
n, m = size(C)
quat.(C[1:n÷2, 1:m÷2], C[1:n÷2, m÷2+1:m])
end