MCPcopy Create free account
hub / github.com/PX4/eigen / selfadjoint

Function selfadjoint

test/selfadjoint.cpp:15–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13// the related products and decompositions are tested in specific files.
14
15template<typename MatrixType> void selfadjoint(const MatrixType& m)
16{
17 typedef typename MatrixType::Index Index;
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),
24 m2 = MatrixType::Random(rows, cols),
25 m3(rows, cols),
26 m4(rows, cols);
27
28 m1.diagonal() = m1.diagonal().real().template cast<Scalar>();
29
30 // check selfadjoint to dense
31 m3 = m1.template selfadjointView<Upper>();
32 VERIFY_IS_APPROX(MatrixType(m3.template triangularView<Upper>()), MatrixType(m1.template triangularView<Upper>()));
33 VERIFY_IS_APPROX(m3, m3.adjoint());
34
35 m3 = m1.template selfadjointView<Lower>();
36 VERIFY_IS_APPROX(MatrixType(m3.template triangularView<Lower>()), MatrixType(m1.template triangularView<Lower>()));
37 VERIFY_IS_APPROX(m3, m3.adjoint());
38
39 m3 = m1.template selfadjointView<Upper>();
40 m4 = m2;
41 m4 += m1.template selfadjointView<Upper>();
42 VERIFY_IS_APPROX(m4, m2+m3);
43
44 m3 = m1.template selfadjointView<Lower>();
45 m4 = m2;
46 m4 -= m1.template selfadjointView<Lower>();
47 VERIFY_IS_APPROX(m4, m2-m3);
48}
49
50void bug_159()
51{

Callers 1

test_selfadjointFunction · 0.85

Calls 5

realMethod · 0.80
rowsMethod · 0.45
colsMethod · 0.45
diagonalMethod · 0.45
adjointMethod · 0.45

Tested by 1

test_selfadjointFunction · 0.68