selfadjoint.cpp File Reference
#include "main.h"

Macros

#define TEST_CHECK_STATIC_ASSERTIONS
 

Functions

template<typename MatrixType >
void selfadjoint (const MatrixType &m)
 
void bug_159 ()
 
 EIGEN_DECLARE_TEST (selfadjoint)
 

Macro Definition Documentation

◆ TEST_CHECK_STATIC_ASSERTIONS

#define TEST_CHECK_STATIC_ASSERTIONS

Function Documentation

◆ bug_159()

void bug_159 ( )
47  {
48  Matrix3d m = Matrix3d::Random().selfadjointView<Lower>();
50 }
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:966
@ Lower
Definition: Constants.h:211
int * m
Definition: level2_cplx_impl.h:294

References EIGEN_UNUSED_VARIABLE, Eigen::Lower, and m.

Referenced by EIGEN_DECLARE_TEST().

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( selfadjoint  )
52  {
53  for (int i = 0; i < g_repeat; i++) {
54  int s = internal::random<int>(1, EIGEN_TEST_MAX_SIZE);
55 
58  CALL_SUBTEST_3(selfadjoint(Matrix3cf()));
59  CALL_SUBTEST_4(selfadjoint(MatrixXcd(s, s)));
61 
63  }
64 
66 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_TEST_MAX_SIZE
Definition: boostmultiprec.cpp:16
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
RealScalar s
Definition: level1_cplx_impl.h:130
#define TEST_SET_BUT_UNUSED_VARIABLE(X)
Definition: main.h:139
static int g_repeat
Definition: main.h:191
void selfadjoint(const MatrixType &m)
Definition: selfadjoint.cpp:17
void bug_159()
Definition: selfadjoint.cpp:47
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
#define CALL_SUBTEST_5(FUNC)
Definition: split_test_helper.h:28
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22

References bug_159(), CALL_SUBTEST_1, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, EIGEN_TEST_MAX_SIZE, Eigen::g_repeat, i, s, selfadjoint(), and TEST_SET_BUT_UNUSED_VARIABLE.

◆ selfadjoint()

template<typename MatrixType >
void selfadjoint ( const MatrixType m)
17  {
18  typedef typename MatrixType::Scalar Scalar;
19 
20  Index rows = m.rows();
21  Index cols = m.cols();
22 
23  MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3(rows, cols), m4(rows, cols);
24 
25  m1.diagonal() = m1.diagonal().real().template cast<Scalar>();
26 
27  // check selfadjoint to dense
28  m3 = m1.template selfadjointView<Upper>();
29  VERIFY_IS_APPROX(MatrixType(m3.template triangularView<Upper>()), MatrixType(m1.template triangularView<Upper>()));
30  VERIFY_IS_APPROX(m3, m3.adjoint());
31 
32  m3 = m1.template selfadjointView<Lower>();
33  VERIFY_IS_APPROX(MatrixType(m3.template triangularView<Lower>()), MatrixType(m1.template triangularView<Lower>()));
34  VERIFY_IS_APPROX(m3, m3.adjoint());
35 
36  m3 = m1.template selfadjointView<Upper>();
37  m4 = m2;
38  m4 += m1.template selfadjointView<Upper>();
39  VERIFY_IS_APPROX(m4, m2 + m3);
40 
41  m3 = m1.template selfadjointView<Lower>();
42  m4 = m2;
43  m4 -= m1.template selfadjointView<Lower>();
44  VERIFY_IS_APPROX(m4, m2 - m3);
45 }
Matrix3d m1
Definition: IOFormat.cpp:2
MatrixType m2(n_dims)
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83

References cols, m, m1, m2(), rows, and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().