# forum.alglib.net

ALGLIB forum
 It is currently Fri Sep 20, 2024 11:13 am

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Generalized eigenvaluesPosted: Thu May 21, 2020 12:03 pm

Joined: Thu May 07, 2020 11:26 am
Posts: 1
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.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 1 post ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 55 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: