Added functions for matrices to work with quaternion inputs.