Re: [eigen] inconsistency in fast eigen decomposition

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Here's more output:

Original Matrix:
           0.000536227 -1.56178e-05 -9.47391e-05
          -1.56178e-05  0.000297322 -0.000148785
          -9.47391e-05 -0.000148785   9.7827e-05
-----
[SelfAdjointEigenSolver] Eigen vectors:
          -0.168841 0.161623 0.972302
          -0.451632 -0.889498 0.0694328
          -0.876083    0.4274 -0.223178
[SelfAdjointEigenSolver] Eigen values: 2.86806e-06 0.00037165 0.000556858
[SelfAdjointEigenSolver] EigVec * EigVal.asDiag * EigVec.adj
           0.000536227 -1.56178e-05 -9.47391e-05
          -1.56178e-05  0.000297322 -0.000148785
          -9.47391e-05 -0.000148785   9.7827e-05
[SelfAdjointEigenSolver] EigVec * EigVec.adj
                     1  2.23517e-08 -2.98023e-08
           2.23517e-08            1 -1.21072e-08
          -2.98023e-08 -1.21072e-08            1
----
[old::eigen33] Eigen vectors:
           0.168841 -0.161623 -0.972302
            0.451632   0.889499 -0.0694332
          0.876083  -0.4274 0.223178
[old::eigen33] Eigen values: 2.86801e-06 0.00037165 0.000556858
[old::eigen33] EigVec * EigVal.asDiag * EigVec.adj
           0.000536227 -1.56176e-05 -9.47394e-05
          -1.56176e-05  0.000297322 -0.000148785
          -9.47394e-05 -0.000148785  9.78271e-05
[old::eigen33] EigVec * EigVec.adj
                     1  3.12924e-07 -4.76837e-07
           3.12924e-07            1 -9.68575e-08
          -4.76837e-07 -9.68575e-08            1
----
[new::eigen33] Eigen vectors:
           0.222612 0.0712298 -0.972302
            0.015897   -0.99746 -0.0694332
          0.974778        0 0.223178
[new::eigen33] Eigen values: 2.86801e-06 0.00037165 0.000556858
[new::eigen33] EigVec * EigVal.asDiag * EigVec.adj
           0.000528465  1.11983e-05 -0.000120214
           1.11983e-05   0.00037245 -8.58462e-06
          -0.000120214 -8.58462e-06  3.04615e-05
[new::eigen33] EigVec * EigVec.adj
                     1 -7.45058e-09  2.98023e-08
          -7.45058e-09           1 1.86265e-09
          2.98023e-08 1.86265e-09           1



The old::eigen33 and SelfAdjointEigenSolver (and matlab too) return the correct results.

The new::eigen33 doesn't.


Cheers,
Radu.
--
http://pointclouds.org

On 02/03/2011 12:00 PM, Radu Bogdan Rusu wrote:
Ok, I am comparing the output of: SelfAdjointEigenSolver, old eigen33, new eigen33 for:

covariance_matrix_f << 0.000536227, -1.56178e-05, -9.47391e-05, -1.56178e-05, 0.000297322, -0.000148785, -9.47391e-05,
-0.000148785, 9.7827e-05;


-0.168841 0.161623 0.972302
-0.451632 -0.889498 0.0694328
-0.876083 0.4274 -0.223178
2.86806e-06
0.00037165
0.000556858
Normal: -0.168841, -0.451632, -0.876083
[SelfAdjointEigenSolver] 0.126838 seconds.

0.168841 -0.161623 -0.972302
0.451632 0.889499 -0.0694332
0.876083 -0.4274 0.223178
2.86801e-06
0.00037165
0.000556858
Normal: 0.168841, 0.451632, 0.876083
[old::eigen33] 0.053951 seconds.

0.222612 0.0712298 -0.972302
0.015897 -0.99746 -0.0694332
0.974778 0 0.223178
2.86801e-06
0.00037165
0.000556858
Normal: 0.222612, 0.015897, 0.974778
[new::eigen33] 0.0587709 seconds.


The weird thing here is that the old eigen33 was giving approximately the same results (minus the sign) as
SelfAdjointEigenSolver, while the new one seems to return different results.

Cheers,
Radu.
--
http://pointclouds.org

On 02/03/2011 09:02 AM, Radu Bogdan Rusu wrote:
Gael, Benoit,

Many thanks for the prompt replies.

On 02/03/2011 02:29 AM, Gael Guennebaud wrote:
Hi,

indeed, the code to extract the eigen vectors was quite naive. I've
committed a more accurate version which should work fine for most use
cases.

Thanks, I'll pick it up from bench/eig33.cpp again. :)

Cheers,
Radu.
--
http://pointclouds.org


I assume you are doing planar fit right? If so then the new version
should really really be enough for you. It lacks some accuracy (but
not too bad) only when all eigenvalues are relatively closed to each
other. In this case there is no good planar approximation anyway.

gael

On Thu, Feb 3, 2011 at 7:41 AM, Radu Bogdan Rusu<rusu@xxxxxxxxxxxxxxxx> wrote:
Hi all,

Gael, we've been using the fast eigen decomposition suggested by you in an
e-mail back in 09/02/10 (regarding SelfAdjointEigenSolver<Matrix3f> -
http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2010/08/msg00283.html)
without any major issues for the past few months.

We've recently hit a problem, and I was wondering whether there is a fix for
it that doesn't involve switching to another SVD/eigendecomposition method
in Eigen, as the implementation that we're using (see attached source) is
still blazing fast.

Here's the snippet of code that exhibits the problem (not that it's a c&p so
please ignore the style/format):

Eigen3::Matrix3f covariance_matrix_f;
covariance_matrix_f<< 5.64909, 5.64909, 0.0860435, 5.64909, 5.64909,
0.0860435, 0.0860435, 0.0860435, 2.92133;

Eigen3::SelfAdjointEigenSolver<Eigen3::Matrix3f> ei_symm
(covariance_matrix_f);
Eigen3::Vector3f eigen_values = ei_symm.eigenvalues ();
Eigen3::Matrix3f eigen_vectors = ei_symm.eigenvectors ();

cerr<< eigen_vectors<< endl;
cerr<< eigen_values<< endl;
cerr<< "Normal: "<< eigen_vectors (0, 0)<< ", "<< eigen_vectors (1, 0)
<< ", "<< eigen_vectors (2, 0)<< endl;

Eigen3::Vector3f eigen_val;
Eigen3::Matrix3f eigen_vec;
eigen33 (covariance_matrix_f, eigen_vec, eigen_val);

cerr<< eigen_vec<< endl;
cerr<< eigen_val<< endl;
cerr<< "Normal: "<< eigen_vec (0, 0)<< ", "<< eigen_vec (1, 0)<< ","
<< eigen_vec (2, 0)<< endl;
----

The output is:

0.707107 -0.0102705 0.707032
-0.707107 -0.0102656 0.707032
3.48268e-06 0.999894 0.0145212
3.41638e-08
2.91956
11.2999
Normal: 0.707107, -0.707107, 3.48268e-06

-0.00781202 0.0102683 0.707032
-0.00781202 0.0102683 0.707032
0.999939 -0.999895 0.0145207
-1.01014e-06
2.91956
11.2999
Normal: -0.00781202, -0.00781202, 0.999939
---


Thanks in advance.


Cheers,
Radu.
--
http://pointclouds.org






Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/