# How to do a Generalized Complex Schur (or QZ) Decomposition with Eigen C++? [closed]

I would like to do a Generalized Schur (or QZ) decomposition for a pair of complex matrices $A$ and $B$.

I found the following class:

class Eigen::GeneralizedEigenSolver<_MatrixType>


but it seems that it only works for real matrices. Any ideas?

## closed as off-topic by Brian Borchers, Christian Clason, Kirill, Mauro Vanzetto, DeathbreathMar 2 '18 at 15:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

• Are you asking for alternative software packages, or whether Eigen can do that? – Wolfgang Bangerth Feb 21 '18 at 1:12
• Can Eigen do that? – RangerBob Feb 21 '18 at 6:58
• I have no idea. I'm asking what exactly you are asking in your original question. – Wolfgang Bangerth Feb 21 '18 at 7:46
• Do you know alternative software packages? – RangerBob Feb 21 '18 at 20:22
• No, I don't, actually. It's not my field :-) – Wolfgang Bangerth Feb 22 '18 at 23:24

## 1 Answer

Numerical computation of Generalized Complex Schur decomposition can be performed by calling zgges() LAPACK function. For example, see NETLIB zgees documentation, or a documentation for any other BLAS/LAPACK library implementation.

Eigen is technically nothing else, but a very convenient templated library of wrappers and algorithms, also including some custom implementation. However, for maximum Eigen performance, it is recommended to link it to a LAPACK\BLAS library, for example, Intel MKL.

Now, regarding Schur decomposition in Eigen. I have not used the functionality from GeneralizedEigenSolver, but according to the documentation, only real matrices are supported. The following code compiles correctly:

Eigen::GeneralizedEigenSolver<Eigen::MatrixXf> solver;
Eigen::MatrixXf A(4,4),B(4,4);
solver.compute(A,B);


However, the complex version results in a compilation error that pretty much describes itself: no support for complex matrices yet:

Eigen::GeneralizedEigenSolver<Eigen::MatrixXcd> solver;
Eigen::MatrixXcd A(4,4),B(4,4);
solver.compute(A,B);

Eigen/src/Eigenvalues/GeneralizedEigenSolver.h:367:20: error: no viable conversion from 'CoeffReturnType' (aka 'const std::__1::complex<double>') to 'RealScalar' (aka 'double')


The example is tested on Eigen 3.3.4. So, I would suggest you to use LAPACK function directly (you have to have some BLAS\LAPACK library connected to your code) without using Eigen wrappers for now.