after your blog, a modified version with some extensions inside...
Code:
// Quaternion by Eddie W. Shore
EXPORT QTM(A,B,C,D)
BEGIN
RETURN [[A+B*i, C+D*i],
[-C+D*i, A-B*i]];
END;
// Norm
EXPORT QTM_norm(A,B,C,D)
BEGIN
RETURN sqrt(A^2+B^2+C^2+D^2);
END;
// Unit Quaternion matrix
EXPORT QTM_Unit(A,B,C,D)
BEGIN
LOCAL mat, n;
mat:= QTM(A,B,C,D);
n:= QTM_norm(A,B,C,D);
RETURN mat/n;
END;
// Conjugate of Q. matrix
EXPORT QTM_conj(A,B,C,D)
BEGIN
RETURN (QTM(A,B,C,D))^(-1) * QTM_norm(A,B,C,D)^2;
END;