hessenberg.cpp
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #include "main.h"
12 #include <Eigen/Eigenvalues>
13 
14 template<typename Scalar,int Size> void hessenberg(int size = Size)
15 {
17 
18  // Test basic functionality: A = U H U* and H is Hessenberg
19  for(int counter = 0; counter < g_repeat; ++counter) {
20  MatrixType m = MatrixType::Random(size,size);
22  MatrixType Q = hess.matrixQ();
23  MatrixType H = hess.matrixH();
24  VERIFY_IS_APPROX(m, Q * H * Q.adjoint());
25  for(int row = 2; row < size; ++row) {
26  for(int col = 0; col < row-1; ++col) {
27  VERIFY(H(row,col) == (typename MatrixType::Scalar)0);
28  }
29  }
30  }
31 
32  // Test whether compute() and constructor returns same result
33  MatrixType A = MatrixType::Random(size, size);
35  cs1.compute(A);
37  VERIFY_IS_EQUAL(cs1.matrixH().eval(), cs2.matrixH().eval());
38  MatrixType cs1Q = cs1.matrixQ();
39  MatrixType cs2Q = cs2.matrixQ();
40  VERIFY_IS_EQUAL(cs1Q, cs2Q);
41 
42  // Test assertions for when used uninitialized
43  HessenbergDecomposition<MatrixType> hessUninitialized;
44  VERIFY_RAISES_ASSERT( hessUninitialized.matrixH() );
45  VERIFY_RAISES_ASSERT( hessUninitialized.matrixQ() );
46  VERIFY_RAISES_ASSERT( hessUninitialized.householderCoefficients() );
47  VERIFY_RAISES_ASSERT( hessUninitialized.packedMatrix() );
48 
49  // TODO: Add tests for packedMatrix() and householderCoefficients()
50 }
51 
53 {
54  CALL_SUBTEST_1(( hessenberg<std::complex<double>,1>() ));
55  CALL_SUBTEST_2(( hessenberg<std::complex<double>,2>() ));
56  CALL_SUBTEST_3(( hessenberg<std::complex<float>,4>() ));
57  CALL_SUBTEST_4(( hessenberg<float,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)) ));
58  CALL_SUBTEST_5(( hessenberg<std::complex<double>,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE)) ));
59 
60  // Test problem size constructors
61  CALL_SUBTEST_6(HessenbergDecomposition<MatrixXf>(10));
62 }
Matrix3f m
SCALAR Scalar
Definition: bench_gemm.cpp:33
#define VERIFY_RAISES_ASSERT(a)
Definition: main.h:285
const MatrixType & packedMatrix() const
Returns the internal representation of the decomposition.
HouseholderSequenceType matrixQ() const
Reconstructs the orthogonal matrix Q in the decomposition.
MatrixHReturnType matrixH() const
Constructs the Hessenberg matrix H in the decomposition.
MatrixXf MatrixType
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
#define VERIFY_IS_APPROX(a, b)
HessenbergDecomposition & compute(const EigenBase< InputType > &matrix)
Computes Hessenberg decomposition of given matrix.
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:331
m row(1)
static int g_repeat
Definition: main.h:144
void hessenberg(int size=Size)
Definition: hessenberg.cpp:14
#define VERIFY(a)
Definition: main.h:325
#define EIGEN_TEST_MAX_SIZE
The quaternion class used to represent 3D orientations and rotations.
m col(1)
const int Dynamic
Definition: Constants.h:21
The matrix class, also used for vectors and row-vectors.
const CoeffVectorType & householderCoefficients() const
Returns the Householder coefficients.
void test_hessenberg()
Definition: hessenberg.cpp:52


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:10