QR Decomposition on Quaternion Matrices

Building a quaternion QR decomposition library in C using Householdertransformations or Givensrotations.

What are Quaternions?

Quaternions are an extension of the complex numbers. They are a four-dimenstional associative normed division algebra over real numbers. Multiplication of quaternions is non commutative.

$q_1 q_2 \neq q_2 q_1 \text{for} q_1 , q_2 \in \mathbb{H}$

First we define a quaternion element in C:

quaternion_t *quaternion_new_set(double q1, double q2, double q3, double q4)
{
    quaternion_t *q = malloc(sizeof(quaternion_t));
    if (q != NULL) {
        q->q[0] = q1; q->q[1] = q2; q->q[2] = q3; q->q[3] = q4;
    }
    return q;
}