SVD in Lapack is suboptimal, by means of Givens rotations vs. Hauseholder mirroring (Feature #3018)


Added by Zoltan Prohaszka almost 12 years ago. Updated over 9 years ago.


Status:Open Start date:2013-05-11
Priority:Normal Due date:
Assignee:Zoltan Prohaszka % Done:

0%

Category:core
Target version:-
Difficulty: Pull request:

Description

Most Multiple View Computer Vision Algorithms have to
solve overdetermined homogeneous linear equations, for
which Singular Value Decomposition (SVD) is the proper method.

The SVD implementation given in Lapack achieves band diagonal shape
by applying Givens rotations. Hausholder mirroring transformations
can zero a partial row for once, not only one element, thus there are
faster by a factor of n. (the smallest size of the input matrix)

A typipical 3D reconstruction algorithm may spend many time by finding inliers
of a proper motion stereo model by RANSAC.
For a not so easy image pair, RANSAC (inside findfundamental())
executes 8x8 SVD several hundred times.

An other example, the JAMA package of NIST uses Hauseholder transformations.
(I attach a commented version of the algorithm, and the original
file also). The JAMA package have another attractive feature regarding
the eigenvalue-decomposition of non-symmetric matrices: It contains
the random step introduced by the MATLAB team to avoid the algorithm to stuck.
(It can be tested by big permutation matrices).

The JAMA package comes with very liberate licence.
It has also disadvantages:
-Most numerical loops are designed to work only with rectangular matrices of
one orientation ('landscape' or 'portrait'), so wrapper routines would be needed
for universal functionality.
-It is not implemented to take advantage of SIMD or multithreaded execution.
-It contains some calculations which give numeric stability very near to
the margin of floating numeric represantations, but results slower execution
in other, common cases (hypot and division instead of multiplication by reciprocal).
I did not analize how unsafe the faster versions would be, so I did not modify these
for my versions.

I would like to ask for the opinion of the community, how the better functionality
should be incorporated in openCV.

Regards:
zol

I set the priority normal because SVD is executed frequently. Otherwise I would give Low.


c_jama_svd.h - JAMA SVD file modified for my purpose, then bidiagonalization commented. M_:k denotes MATLAB M(:,k) in comments beginning with initials PZ (21 kB) Zoltan Prohaszka, 2013-05-11 06:17 pm


Associated revisions

Revision d01ca30f
Added by Vadim Pisarevsky over 10 years ago

Merge pull request #3018 from fradelg:master

History

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4570

Also available in: Atom PDF