why is cv::invert so incredibly slow?
hi,
why is cv::invert so incredibly slow?
inverting a 465x465 matrix using svd takes 2minutes.
without svd it still takes ~2sec
octave is much faster
i try to invert a 48984x465 matrix (SVD) and it takes a lot of time (it does not even completed yet) to invert.
using octaves pinv finishes in <20sec;
calculating inv(R'*R)*R'
in octave takes <10sec
in opencv (without SVD) it also took much more time than my patience allowed me to wait.
I use 2.4.1
has anyone a hint?
edit: the second test (inv(R'R)R') was done in debug. obviously it should finish in same time as the first one)
Edit2:
i did some tests with the 2.4.8 ocv version:
version:
inverting 48984 x 465 matrix with SVD took 10min
10min
inverting 48984 x 465 matrix without SVD (inv(R'R)R') took 18s (only measured the inv(R'*R) part)
inverting 465 x 465 matrix with SVD took 5s
5s
inverting 465 x 465 matrix without SVD took 0.5s
indeed there is a speed up in later opencv versions.
octave timings:
timings:
tic; pinv(rand(465,465)); toc -> Elapsed time is 1.232 seconds.
seconds.
tic; inv(rand(465,465)); toc -> Elapsed time is 0.0780001 seconds.
seconds.
tic; pinv(rand(48984,465)); toc -> Elapsed time is 15.023 seconds.
R = rand(48984,465); tic;inv(R'*R);toc --> Elapsed time is 0.889 seconds.
In comparistion to octave that afaik also uses SVD to calculate pseudoinverses opencv implementation seems to be very slow. But also the normal inversion does not compare very well.