// QR factorization of H using Givens rotations
for (int k = 0; k < i; ++k)
rotation[k].apply(H, i, k, k + 1);
rotation[i] = new GivensRotation(H.get(i, i), H.get(i + 1, i));
rotation[i].apply(H, i, i, i + 1);
rotation[i].apply(s, i, i + 1);
}
// Update solution in current subspace