forum.alglib.net

ALGLIB forum
It is currently Thu Dec 12, 2024 4:25 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.



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Generalized eigenvalues
PostPosted: Thu May 21, 2020 12:03 pm 
Offline

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group