## Re: [Vxl-users] Eigenvectors using VNL vs Matlab

 Re: [Vxl-users] Eigenvectors using VNL vs Matlab From: Kongbin Kang - 2005-05-10 20:04:48 ```Amitha Perera wrote: >On Tue 10 May 2005, maziyar wrote: > > >>I have tried using: >> >>vnl_symmetric_eigensystem eig(cov(data.transpose())); >>vcl_cerr << eig.V << vcl_endl; >>vcl_cerr << eig.D << vcl_endl; >> >>to find the eigenvalues and the eigenvectors for a covariance matrix. When >>comparing my results to those of Matlab, I am producing similiar eigenvalues, >>however, my eigenvectors are not the same. >> >>Is this an expected result due to the different algorithms used by the two >>systems, or should they yield the same result. >> >> > > > If the matrix is none-degenerate, the eigenvectors of the matrix should be unique upto a scale. It means matlab or vxl should be different only up to the machine accuracy. But for degenerate matrix, the solution to eigenvector is not unique so that it is normal to have different eigenvectors. If you can post the eigen values, eigenvectors and your matrix, we may find out whether it is normal or not to have difference between vxl and matlab. ```

### Thread view

 [Vxl-users] Eigenvectors using VNL vs Matlab From: maziyar - 2005-05-10 15:25:35 ```I have tried using: vnl_symmetric_eigensystem eig(cov(data.transpose())); vcl_cerr << eig.V << vcl_endl; vcl_cerr << eig.D << vcl_endl; to find the eigenvalues and the eigenvectors for a covariance matrix. When comparing my results to those of Matlab, I am producing similiar eigenvalues, however, my eigenvectors are not the same. Is this an expected result due to the different algorithms used by the two systems, or should they yield the same result. In matlab, i am simply using: [v,d] = eig(cov(data.')). Thanks, Maz Khorasani ```
 Re: [Vxl-users] Eigenvectors using VNL vs Matlab From: Amitha Perera - 2005-05-10 19:42:55 ```On Tue 10 May 2005, maziyar wrote: > I have tried using: > > vnl_symmetric_eigensystem eig(cov(data.transpose())); > vcl_cerr << eig.V << vcl_endl; > vcl_cerr << eig.D << vcl_endl; > > to find the eigenvalues and the eigenvectors for a covariance matrix. When > comparing my results to those of Matlab, I am producing similiar eigenvalues, > however, my eigenvectors are not the same. > > Is this an expected result due to the different algorithms used by the two > systems, or should they yield the same result. In general, Matlab algorithms are not the same as those used in vxl, so the results could be different. If the results from vxl actually are eigenvectors, then I don't see a problem. If they aren't, well, something needs to be done. Amitha. ```
 Re: [Vxl-users] Eigenvectors using VNL vs Matlab From: Kongbin Kang - 2005-05-10 20:04:48 ```Amitha Perera wrote: >On Tue 10 May 2005, maziyar wrote: > > >>I have tried using: >> >>vnl_symmetric_eigensystem eig(cov(data.transpose())); >>vcl_cerr << eig.V << vcl_endl; >>vcl_cerr << eig.D << vcl_endl; >> >>to find the eigenvalues and the eigenvectors for a covariance matrix. When >>comparing my results to those of Matlab, I am producing similiar eigenvalues, >>however, my eigenvectors are not the same. >> >>Is this an expected result due to the different algorithms used by the two >>systems, or should they yield the same result. >> >> > > > If the matrix is none-degenerate, the eigenvectors of the matrix should be unique upto a scale. It means matlab or vxl should be different only up to the machine accuracy. But for degenerate matrix, the solution to eigenvector is not unique so that it is normal to have different eigenvectors. If you can post the eigen values, eigenvectors and your matrix, we may find out whether it is normal or not to have difference between vxl and matlab. ```