Accessible implementations of linear algebra algorithms
QR-PerfTest.cpp
Compares the performance of the naive included QR algorithm with Eigen's implementation.
The results on an i7-7700HQ were:
For small matrices, the naive implementation is slightly faster than Eigen. For matrices larger than 100×100, Eigen is significantly faster because it uses a blocked algorithm that makes more efficient use of the CPU's cache.
The Frobenius norm of the error ‖A - QR‖ is around twice as big for the naive implementation than for Eigen's implementation.
For example, for a 100×100 matrix, the naive implementation has an absolute error of 5.58e-14, while Eigen's implementation has an error of 3.58e-14.
It's a small difference, and I don't have an exact explanation for it, but the reason could be that Eigen uses a different normalization factor for the Householder reflectors:
The naive implementation normalizes them as wₖ = √2·vₖ / ‖vₖ‖, such that ‖wₖ‖ = √2, while Eigen follows the same convention used by LAPACK, where wₖ = vₖ / vₖ[0], such that wₖ[0] = 1.