Added a Hessenberg decomposition class for both real and complex matrices.

This is the first step towards a non-selfadjoint eigen solver.
Notes:
 - We might consider merging Tridiagonalization and Hessenberg toghether ?
 - Or we could factorize some code into a Householder class (could also be shared with QR)
This commit is contained in:
Gael Guennebaud
2008-06-08 15:03:23 +00:00
parent 4dd57b585d
commit e3fac69f19
6 changed files with 287 additions and 5 deletions

View File

@@ -54,9 +54,11 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
void test_eigensolver()
{
for(int i = 0; i < 1; i++) {
// very important to test a 3x3 matrix since we provide a special path for it
CALL_SUBTEST( eigensolver(Matrix3f()) );
CALL_SUBTEST( eigensolver(Matrix4d()) );
CALL_SUBTEST( eigensolver(MatrixXd(7,7)) );
CALL_SUBTEST( eigensolver(MatrixXcd(6,6)) );
CALL_SUBTEST( eigensolver(MatrixXcd(3,3)) );
}
}

View File

@@ -22,7 +22,9 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
// this hack is needed to make this file compiles with -pedantic (gcc)
#define throw(X)
// discard vectorization since operator new is not called in that case
#define EIGEN_DONT_VECTORIZE 1
#include "main.h"

View File

@@ -39,17 +39,31 @@ template<typename MatrixType> void qr(const MatrixType& m)
MatrixType a = MatrixType::random(rows,cols);
QR<MatrixType> qrOfA(a);
VERIFY_IS_APPROX(a, qrOfA.matrixQ() * qrOfA.matrixR());
VERIFY_IS_NOT_APPROX(a+MatrixType::identity(rows, cols), qrOfA.matrixQ() * qrOfA.matrixR());
SquareMatrixType b = a.adjoint() * a;
// check tridiagonalization
Tridiagonalization<SquareMatrixType> tridiag(b);
VERIFY_IS_APPROX(b, tridiag.matrixQ() * tridiag.matrixT() * tridiag.matrixQ().adjoint());
// check hessenberg decomposition
HessenbergDecomposition<SquareMatrixType> hess(b);
VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
VERIFY_IS_APPROX(tridiag.matrixT(), hess.matrixH());
b = SquareMatrixType::random(cols,cols);
hess.compute(b);
VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
}
void test_qr()
{
for(int i = 0; i < 1; i++) {
CALL_SUBTEST( qr(Matrix2f()) );
CALL_SUBTEST( qr(Matrix3d()) );
CALL_SUBTEST( qr(Matrix4d()) );
CALL_SUBTEST( qr(MatrixXf(12,8)) );
// CALL_SUBTEST( qr(MatrixXcd(17,7)) ); // complex numbers are not supported yet
CALL_SUBTEST( qr(MatrixXcd(5,5)) );
CALL_SUBTEST( qr(MatrixXcd(7,3)) );
}
}