Matrix package:numeric-prelude

Routines and abstractions for Matrices and basic linear algebra over fields or rings. We stick to simple Int indices. Although advanced indices would be nice e.g. for matrices with sub-matrices, this is not easily implemented since arrays do only support a lower and an upper bound but no additional parameters. ToDo: - Matrix inverse, determinant (see htam:Matrix)
The rotation matrix must be normalized. (I.e. no rotation with scaling) The computed quaternion is not normalized.
Map a quaternion to complex valued 2x2 matrix, such that quaternion addition and multiplication is mapped to matrix addition and multiplication. The determinant of the matrix equals the squared quaternion norm (normSqr). Since complex numbers can be turned into real (orthogonal) matrices, a quaternion could also be converted into a real matrix.
Let c be a unit quaternion, then it holds similarity c (0+::x) == toRotationMatrix c * x