'Wrong Eigen Decomposition From Armadillo C++
I'm relatively new to Armadillo and I'm trying to calculate the shared eigenvectors of two dense Matrix. I can't seem to get the correct values compared to python or a simple eigenvector calculator online. I know the python version of this code is correct but I don't know why armadillo isn't working in c++. As a simple test case I've used the code below
mat B = { {1, 2}, {3, 4} };
mat C = { {5, 6}, {0, 3} };
cx_mat col_vec;
cx_vec eig;
eig_pair( eig, col_vec, B, C);
col_vec.print("eigenvector");
Armadillo Result:
eigenvector
(-1.000e+00,+0.000e+00) (+7.653e-01,+0.000e+00)
(+6.377e-01,+0.000e+00) (-1.000e+00,+0.000e+00)
If I compute the eigenvector in python I get a completely different result as seen below
H_2 = np.array([[1, 2],[3, 4]])
S_2 = np.array([[5, 6],[0, 3]])
eigval, eig_vec = sp.linalg.eigh(H_2, S_2)
print(eig_vec)
Python Result:
[[-0.39880251 0.20237727]
[ 0.26126793 0.51485182]]
I have no idea why this is the case and would really appreciate some help in calculating the correct eigenvalues in armadillo. If it's important at all I'm using WSL Ubuntu.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
