NikolausDemmel / rootba

Square Root Bundle Adjustment for Large-Scale Reconstruction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QR decomposition via Givens roation vs Householder transform?

hitdshu opened this issue · comments

Hi,

Thanks for your excellent work.

In your works, you use the householder transform to perform QR decomposition. While in MSCKF related literatures, they usually use Givens rotation.

After some search, I realize that they have the same level of accuracy (both are better than Schmidt orthogonalization). So why you use householder transform instead of Givens rotation. Is Householder transform really faster than Givens rotation?

Best,
Deshun

Thanks for your interest.

I don't have any great theoretical insights, but I agree that I would also expect the same accuracy from Givens rotations and Householder refelections for computing the QR.

I haven't compared number of operations. The main advantage of Householder reflections in my mind is that you can zero out a whole column of matrix elements, where Givens rotations zero our elements one at a time. So maybe computing and applying Householder reflections is better suited to (automatic) vectorization in the CPU. Householder reflections are also more compact to store (in a way that is efficient to apply). In Eigen you can do a Householder QR decomposition in-place, storing the householder vectors in the columns that would otherwise be zero. Storage overhead is only 1 scalar per column. Storing Given's rotations (at least with the Eigen::JacobiRotation class), you have 1 extra scalar per zero element.

In rootba we actually use both. For initial marginalization in the landmark blocks there are both variants as perform_qr_givens() and perform_qr_householder(), and to apply and remove damping, we always use Givens rotations in set_landmark_damping().

For the former, you can experiment yourself about the runtime difference by setting the solver. use_householder_marginalization option. For the marginalization we found it only makes a small difference (Householder is a little faster) and since typically landmark marginalization is a small fraction of overall runtime, I don't think the difference is really noticeable for total runtime.

Thanks for your very quick response. Your answer is very appreciated. And I will try to do experiments with both operations.

Have a nice day,
Deshun