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
62 }
H
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
Definition: gnuplot_common_settings.hh:74
hessenberg
void hessenberg(int size=Size)
Definition: hessenberg.cpp:14
col
m col(1)
Eigen::HessenbergDecomposition::compute
HessenbergDecomposition & compute(const EigenBase< InputType > &matrix)
Computes Hessenberg decomposition of given matrix.
Definition: HessenbergDecomposition.h:152
Eigen::HessenbergDecomposition::matrixQ
HouseholderSequenceType matrixQ() const
Reconstructs the orthogonal matrix Q in the decomposition.
Definition: HessenbergDecomposition.h:234
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:386
Eigen::HessenbergDecomposition::packedMatrix
const MatrixType & packedMatrix() const
Returns the internal representation of the decomposition.
Definition: HessenbergDecomposition.h:214
Eigen::HessenbergDecomposition::householderCoefficients
const CoeffVectorType & householderCoefficients() const
Returns the Householder coefficients.
Definition: HessenbergDecomposition.h:179
Eigen::HessenbergDecomposition::matrixH
MatrixHReturnType matrixH() const
Constructs the Hessenberg matrix H in the decomposition.
Definition: HessenbergDecomposition.h:262
VERIFY_RAISES_ASSERT
#define VERIFY_RAISES_ASSERT(a)
Definition: main.h:340
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
CALL_SUBTEST_4
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22
CALL_SUBTEST_3
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
CALL_SUBTEST_1
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
CALL_SUBTEST_5
#define CALL_SUBTEST_5(FUNC)
Definition: split_test_helper.h:28
Eigen::g_repeat
static int g_repeat
Definition: main.h:169
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
CALL_SUBTEST_6
#define CALL_SUBTEST_6(FUNC)
Definition: split_test_helper.h:34
CALL_SUBTEST_2
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:15
Eigen::Quaternion
The quaternion class used to represent 3D orientations and rotations.
Definition: ForwardDeclarations.h:293
main.h
row
m row(1)
EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE
Definition: boostmultiprec.cpp:16
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(hessenberg)
Definition: hessenberg.cpp:52
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
Eigen::HessenbergDecomposition< MatrixType >
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
VERIFY
#define VERIFY(a)
Definition: main.h:380


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:38