forum.alglib.net http://forum.alglib.net/ |
|
Generalized eigenvalues http://forum.alglib.net/viewtopic.php?f=2&t=4326 |
Page 1 of 1 |
Author: | denkir77 [ Thu May 21, 2020 12:03 pm ] |
Post subject: | Generalized eigenvalues |
I have 2 matrices. Code: F = -0.1000 0.0200 0.0200 0.0104 1.0000 0 0 0 0 1.0000 0 0 0 0 1.0000 0 F1 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 I need to calculate the generalized eigenvalues of these 2 matrices in ALGLIB. I found alglib::smatrixgevd() function. But as far as I can see, it doesn't return complex values. I've already done that in MATLAB and Visual Studio (Eigen library). 1) Matlab code: Code: F=[-0.1,0.02,0.02,0.0104;1,0,0,0;0,1,0,0;0,0,1,0]; F1=[1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1]; eigenvalues = eig(F,F1); |---------------------------------------------------------------------------| The results is: eigenvalues = 0.3531 + 0.0000i -0.0723 + 0.3003i -0.0723 - 0.3003i -0.3086 + 0.0000i 2) C++ code (Eigen library): Code: #include <iostream> #include <Eigen/Eigenvalues> using namespace std; using Eigen::MatrixXd; using Eigen::VectorXcd; using Eigen::GeneralizedEigenSolver; int main() { //--- 1) Matrices MatrixXd F_MX(4,4); F_MX.row(0) << -0.1, 0.02, 0.02, 0.0104; F_MX.row(1) << 1, 0, 0, 0; F_MX.row(2) << 0, 1, 0, 0; F_MX.row(3) << 0, 0, 1, 0; MatrixXd F1_MX = MatrixXd::Identity(4, 4); //--- 2) the generalized eigenvalues of square matrices F_MX and F1_MX GeneralizedEigenSolver<MatrixXd> ges; ges.compute(F_MX, F1_MX,true); cout << "The (complex) generalized eigenvalues are (alphas./beta): \n" << ges.eigenvalues() << endl; } |---------------------------------------------------------------------------| The results is: eigenvalues = (0.353145,-0) (-0.0722619,-0.300335) (-0.0722619,0.300335) (-0.308622,0) Please give a hint to solving the problem. Thanks. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |