[vtkusers] Jacobi eigenvectors incorrect?

Bryn Lloyd blloyd at vision.ee.ethz.ch
Fri Oct 30 11:02:37 EDT 2009


David. I certainly don't mind if the code is used. Not sure if 
VTK-developers are interested in having a vtkMatrix class, but you could 
ask / propose an implementation.
The simplest might be to add the functions to vtkMath.



David Doria wrote:
> On Fri, Oct 30, 2009 at 9:05 AM, Bryn Lloyd <blloyd at vision.ee.ethz.ch> wrote:
>> Hi David,
>>
>> I get the same result, using my test code.
>>
>> Matlab:
>> a = [1,2,3; 2,5,9; 3,9,8]
>> [v,w] = eig(a)
>>
>> v =
>>    0.1372    0.9644    0.2259
>>    0.7382   -0.2516    0.6259
>>   -0.6605   -0.0809    0.7464
>>
>>
>> w =
>>   -2.6814         0         0
>>         0    0.2266         0
>>         0         0   16.4547
>>
>>
>> C++:
>> 16.4547         0.225898 -0.964436 0.137232
>> 0.226646        0.625927 0.251645 0.738167
>> -2.68139        0.746449 0.0808535 -0.660513
>>
>> Both are the same, except the sign difference for (ordered) Eigenvector 2.
>> Note that Matlab does not order them.
>>
>> /Bryn
> 
> 
> Bryn,
> 
> I also get the correct result with your code, not sure what I was
> doing wrong, but I'll just use your way. Bill/Bryn - can this code
> that Bryn has written be turned into a vtkMatrix class? I think it is
> insane for users to have to write this:
> 
> template<class TReal>
> TReal **create_matrix(long nrow, long ncol) {
>   typedef TReal* TRealPointer;
>   TReal **m = new TRealPointer[nrow];
> 
>   TReal* block = (TReal*)calloc(nrow*ncol, sizeof(TReal));
>   m[0] = block;
>   for ( int row = 1; row < nrow; ++row ) {
>     m[ row ] = &block[ row * ncol ];
>   }
>   return m;
> }
> 
> in order to get eigen vectors of a matrix.
> 
> Thanks,
> 
> David
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 


-- 
-------------------------------------------------
Bryn Lloyd
Computer Vision Laboratory
ETH Zürich, Sternwartstrasse 7, ETF C110
CH - 8092 Zürich, Switzerland
Tel: +41 44 63 26668
Fax: +41 44 63 21199
-------------------------------------------------



More information about the vtkusers mailing list