Is there a free C or C++ library including a routine for the eigenvalues of a general complex matrix? I checked a number of linear algebra packages like Eigen, but there does not seem to be support for complex matrices.


Eigen can compute eigenvalues of a complex matrix. Take a look at this documentation page:


Here is an Eigen version of a Lapack, zgeev example:

#include <iostream>
#include <complex>
#include <Eigen/Eigenvalues> 

void complexEigenproblem()
  const int n = 4;
  Eigen::MatrixXcd a(n, n);
  typedef std::complex<double> C;
  a <<
    C(-3.97, -5.04), C(-4.11, 3.70), C(-0.34, 1.01), C(1.29, -0.86),
    C(0.34, -1.50), C(1.52, -0.43), C(1.88, -5.38), C(3.36, 0.65),
    C(3.31, -3.85), C(2.50, 3.45), C(0.88, -1.08), C(0.64, -1.48),
    C(-1.10, 0.82), C(1.81, -1.59), C(3.25, 1.33), C(1.57, -3.44);
  Eigen::ComplexEigenSolver<Eigen::MatrixXcd> ces;
  std::cout << "The eigenvalues of a are:" << std::endl << ces.eigenvalues() << std::endl;

The eigenvalues are the same (to five significant digits) as those from zgeev:


(Note: Eigen and zgeev order the output eigenvalues differently)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.