aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2010-03-20 17:04:40 +0000
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2010-03-20 17:04:40 +0000
commitd91ffffc378fe1d7cefd668ea010dfbbbe7967e5 (patch)
treef5eaee47ece147ea57499d0d89ce764eef83a49c /Eigen/src
parentd3e271c47e373146345f411900772d0d2627b0ea (diff)
Allow ComplexEigenSolver and ComplexSchur to work with real matrices.
Add a test which covers this case.
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Eigenvalues/ComplexEigenSolver.h8
-rw-r--r--Eigen/src/Eigenvalues/ComplexSchur.h6
2 files changed, 7 insertions, 7 deletions
diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h
index 86851eca4..7ca87b8cc 100644
--- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h
+++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h
@@ -171,7 +171,7 @@ template<typename _MatrixType> class ComplexEigenSolver
void compute(const MatrixType& matrix);
protected:
- MatrixType m_eivec;
+ EigenvectorType m_eivec;
EigenvalueType m_eivalues;
bool m_isInitialized;
};
@@ -195,21 +195,21 @@ void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix)
m_eivec.setZero();
- Scalar d2, z;
+ Complex d2, z;
RealScalar norm = matrix.norm();
// compute the (normalized) eigenvectors
for(int k=n-1 ; k>=0 ; k--)
{
d2 = schur.matrixT().coeff(k,k);
- m_eivec.coeffRef(k,k) = Scalar(1.0,0.0);
+ m_eivec.coeffRef(k,k) = Complex(1.0,0.0);
for(int i=k-1 ; i>=0 ; i--)
{
m_eivec.coeffRef(i,k) = -schur.matrixT().coeff(i,k);
if(k-i-1>0)
m_eivec.coeffRef(i,k) -= (schur.matrixT().row(i).segment(i+1,k-i-1) * m_eivec.col(k).segment(i+1,k-i-1)).value();
z = schur.matrixT().coeff(i,i) - d2;
- if(z==Scalar(0))
+ if(z==Complex(0))
ei_real_ref(z) = eps * norm;
m_eivec.coeffRef(i,k) = m_eivec.coeff(i,k) / z;
diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h
index 366114d5e..7b20a6621 100644
--- a/Eigen/src/Eigenvalues/ComplexSchur.h
+++ b/Eigen/src/Eigenvalues/ComplexSchur.h
@@ -158,8 +158,8 @@ void ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool skipU)
// TODO skip Q if skipU = true
HessenbergDecomposition<MatrixType> hess(matrix);
- m_matT = hess.matrixH();
- if(!skipU) m_matU = hess.matrixQ();
+ m_matT = hess.matrixH().template cast<Complex>();
+ if(!skipU) m_matU = hess.matrixQ().template cast<Complex>();
// Reduce the Hessenberg matrix m_matT to triangular form by QR iteration.
@@ -221,7 +221,7 @@ void ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool skipU)
// compute the shift kappa as one of the eigenvalues of the 2x2
// diagonal block on the bottom of the active submatrix
- Matrix<Scalar,2,2> t = m_matT.template block<2,2>(iu-1,iu-1);
+ Matrix<Complex,2,2> t = m_matT.template block<2,2>(iu-1,iu-1);
sf = t.cwiseAbs().sum();
t /= sf; // the normalization by sf is to avoid under/overflow