Registered Member
|
I am currently trying to get something rather simple done but it does not work out.
The goal is convert a mathematica notebook into a small c++ tool. The notebook reads a matrix fiddles around with it and then computes the matrix's eigenvalues and eigenvectors. Problem is that the eigenvectors in Mathematica and in my c++ program do not match. After reading the matrix and doing some stuff with it it is the same in both tools:
The eigenvalues are the same:
but the eigenvectors are not: Mathematica
c++:
I do know that the c++ eigenvalues are normalised but it's not just a factor that differs. The methods I used to compute the eigenvectors are: Mathematica
C++
So they are both very simple and I am probably just missing something stupid. Does anyone know what? (Using libeigen 2.0.16-2 and g++ 4.4.6-11) |
Registered Member
|
It looks like the Mathematica eigenvectors are by rows and the
Eigen eigenvectors are by columns. If you transpose the eigenvector matrix from Mathematica, reorder the columns so they are from low to high eigenvalue (like Eigen), and then scale each column, you will get the same eigenvector matrix as Eigen. Bill |
Registered Member
|
Thanks a lot for the info, it really helped me out.
I thought about the difference between row and column vectors but then I didnt quite realise that the vectors are all scaled separately (stupid me) and I did not take negative factors into account. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]