upperbidiagonalization.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) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #include "main.h"
11 #include <Eigen/SVD>
12 
13 template<typename MatrixType> void upperbidiag(const MatrixType& m)
14 {
15  const Index rows = m.rows();
16  const Index cols = m.cols();
17 
20 
21  MatrixType a = MatrixType::Random(rows,cols);
22  internal::UpperBidiagonalization<MatrixType> ubd(a);
23  RealMatrixType b(rows, cols);
24  b.setZero();
25  b.block(0,0,cols,cols) = ubd.bidiagonal();
26  MatrixType c = ubd.householderU() * b * ubd.householderV().adjoint();
28  TransposeMatrixType d = ubd.householderV() * b.adjoint() * ubd.householderU().adjoint();
29  VERIFY_IS_APPROX(a.adjoint(),d);
30 }
31 
32 EIGEN_DECLARE_TEST(upperbidiagonalization)
33 {
34  for(int i = 0; i < g_repeat; i++) {
35  CALL_SUBTEST_1( upperbidiag(MatrixXf(3,3)) );
36  CALL_SUBTEST_2( upperbidiag(MatrixXd(17,12)) );
37  CALL_SUBTEST_3( upperbidiag(MatrixXcf(20,20)) );
38  CALL_SUBTEST_4( upperbidiag(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(16,15)) );
42  }
43 }
d
static const double d[K][N]
Definition: igam.h:11
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
b
Scalar * b
Definition: benchVecAdd.cpp:17
Eigen::RowMajor
@ RowMajor
Definition: Constants.h:321
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
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
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(upperbidiagonalization)
Definition: upperbidiagonalization.cpp:32
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:15
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
main.h
upperbidiag
void upperbidiag(const MatrixType &m)
Definition: upperbidiagonalization.cpp:13
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
cols
int cols
Definition: Tutorial_commainit_02.cpp:1
CALL_SUBTEST_7
#define CALL_SUBTEST_7(FUNC)
Definition: split_test_helper.h:40
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:07:53