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

Functions

template<typename Scalar , int Size, int OtherSize>
void symm (int size=Size, int othersize=OtherSize)
 
 EIGEN_DECLARE_TEST (product_symm)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( product_symm  )
113  {
114  for (int i = 0; i < g_repeat; i++) {
115  CALL_SUBTEST_1((symm<float, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE),
116  internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
117  CALL_SUBTEST_2((symm<double, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE),
118  internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
119  CALL_SUBTEST_3((symm<std::complex<float>, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2),
120  internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2))));
121  CALL_SUBTEST_4((symm<std::complex<double>, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2),
122  internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2))));
123 
124  CALL_SUBTEST_5((symm<float, Dynamic, 1>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
125  CALL_SUBTEST_6((symm<double, Dynamic, 1>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
126  CALL_SUBTEST_7((symm<std::complex<float>, Dynamic, 1>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
127  CALL_SUBTEST_8((symm<std::complex<double>, Dynamic, 1>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
128  }
129 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_TEST_MAX_SIZE
Definition: boostmultiprec.cpp:16
static int g_repeat
Definition: main.h:191
const int Dynamic
Definition: Constants.h:25
void symm(int size=Size, int othersize=OtherSize)
Definition: product_symm.cpp:13
#define CALL_SUBTEST_6(FUNC)
Definition: split_test_helper.h:34
#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_8(FUNC)
Definition: split_test_helper.h:46
#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_7(FUNC)
Definition: split_test_helper.h:40
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22

References CALL_SUBTEST_1, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, CALL_SUBTEST_6, CALL_SUBTEST_7, CALL_SUBTEST_8, Eigen::Dynamic, EIGEN_TEST_MAX_SIZE, Eigen::g_repeat, i, and symm().

◆ symm()

template<typename Scalar , int Size, int OtherSize>
void symm ( int  size = Size,
int  othersize = OtherSize 
)
13  {
17  enum { order = OtherSize == 1 ? 0 : RowMajor };
19 
20  Index rows = size;
21  Index cols = size;
22 
23  MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3;
24 
25  m1 = (m1 + m1.adjoint()).eval();
26 
27  Rhs1 rhs1 = Rhs1::Random(cols, othersize), rhs12(cols, othersize), rhs13(cols, othersize);
28  Rhs2 rhs2 = Rhs2::Random(othersize, rows), rhs22(othersize, rows), rhs23(othersize, rows);
29  Rhs3 rhs3 = Rhs3::Random(cols, othersize), rhs32(cols, othersize), rhs33(cols, othersize);
30 
31  Scalar s1 = internal::random<Scalar>(), s2 = internal::random<Scalar>();
32 
33  m2 = m1.template triangularView<Lower>();
34  m3 = m2.template selfadjointView<Lower>();
35  VERIFY_IS_EQUAL(m1, m3);
36  VERIFY_IS_APPROX(rhs12 = (s1 * m2).template selfadjointView<Lower>() * (s2 * rhs1), rhs13 = (s1 * m1) * (s2 * rhs1));
37 
38  VERIFY_IS_APPROX(rhs12 = (s1 * m2).transpose().template selfadjointView<Upper>() * (s2 * rhs1),
39  rhs13 = (s1 * m1.transpose()) * (s2 * rhs1));
40 
41  VERIFY_IS_APPROX(rhs12 = (s1 * m2).template selfadjointView<Lower>().transpose() * (s2 * rhs1),
42  rhs13 = (s1 * m1.transpose()) * (s2 * rhs1));
43 
44  VERIFY_IS_APPROX(rhs12 = (s1 * m2).conjugate().template selfadjointView<Lower>() * (s2 * rhs1),
45  rhs13 = (s1 * m1).conjugate() * (s2 * rhs1));
46 
47  VERIFY_IS_APPROX(rhs12 = (s1 * m2).template selfadjointView<Lower>().conjugate() * (s2 * rhs1),
48  rhs13 = (s1 * m1).conjugate() * (s2 * rhs1));
49 
50  VERIFY_IS_APPROX(rhs12 = (s1 * m2).adjoint().template selfadjointView<Upper>() * (s2 * rhs1),
51  rhs13 = (s1 * m1).adjoint() * (s2 * rhs1));
52 
53  VERIFY_IS_APPROX(rhs12 = (s1 * m2).template selfadjointView<Lower>().adjoint() * (s2 * rhs1),
54  rhs13 = (s1 * m1).adjoint() * (s2 * rhs1));
55 
56  m2 = m1.template triangularView<Upper>();
57  rhs12.setRandom();
58  rhs13 = rhs12;
59  m3 = m2.template selfadjointView<Upper>();
60  VERIFY_IS_EQUAL(m1, m3);
61  VERIFY_IS_APPROX(rhs12 += (s1 * m2).template selfadjointView<Upper>() * (s2 * rhs1),
62  rhs13 += (s1 * m1) * (s2 * rhs1));
63 
64  m2 = m1.template triangularView<Lower>();
65  VERIFY_IS_APPROX(rhs12 = (s1 * m2).template selfadjointView<Lower>() * (s2 * rhs2.adjoint()),
66  rhs13 = (s1 * m1) * (s2 * rhs2.adjoint()));
67 
68  m2 = m1.template triangularView<Upper>();
69  VERIFY_IS_APPROX(rhs12 = (s1 * m2).template selfadjointView<Upper>() * (s2 * rhs2.adjoint()),
70  rhs13 = (s1 * m1) * (s2 * rhs2.adjoint()));
71 
72  m2 = m1.template triangularView<Upper>();
73  VERIFY_IS_APPROX(rhs12 = (s1 * m2.adjoint()).template selfadjointView<Lower>() * (s2 * rhs2.adjoint()),
74  rhs13 = (s1 * m1.adjoint()) * (s2 * rhs2.adjoint()));
75 
76  // test row major = <...>
77  m2 = m1.template triangularView<Lower>();
78  rhs32.setRandom();
79  rhs13 = rhs32;
80  VERIFY_IS_APPROX(rhs32.noalias() -= (s1 * m2).template selfadjointView<Lower>() * (s2 * rhs3),
81  rhs13 -= (s1 * m1) * (s2 * rhs3));
82 
83  m2 = m1.template triangularView<Upper>();
84  VERIFY_IS_APPROX(rhs32.noalias() = (s1 * m2.adjoint()).template selfadjointView<Lower>() * (s2 * rhs3).conjugate(),
85  rhs13 = (s1 * m1.adjoint()) * (s2 * rhs3).conjugate());
86 
87  m2 = m1.template triangularView<Upper>();
88  rhs13 = rhs12;
89  VERIFY_IS_APPROX(rhs12.noalias() += s1 * ((m2.adjoint()).template selfadjointView<Lower>() * (s2 * rhs3).conjugate()),
90  rhs13 += (s1 * m1.adjoint()) * (s2 * rhs3).conjugate());
91 
92  m2 = m1.template triangularView<Lower>();
93  VERIFY_IS_APPROX(rhs22 = (rhs2) * (m2).template selfadjointView<Lower>(), rhs23 = (rhs2) * (m1));
94  VERIFY_IS_APPROX(rhs22 = (s2 * rhs2) * (s1 * m2).template selfadjointView<Lower>(), rhs23 = (s2 * rhs2) * (s1 * m1));
95 
96  // destination with a non-default inner-stride
97  // see bug 1741
98  {
99  typedef Matrix<Scalar, Dynamic, Dynamic> MatrixX;
100  MatrixX buffer(2 * cols, 2 * othersize);
101  Map<Rhs1, 0, Stride<Dynamic, 2> > map1(buffer.data(), cols, othersize, Stride<Dynamic, 2>(2 * rows, 2));
102  buffer.setZero();
103  VERIFY_IS_APPROX(map1.noalias() = (s1 * m2).template selfadjointView<Lower>() * (s2 * rhs1),
104  rhs13 = (s1 * m1) * (s2 * rhs1));
105 
106  Map<Rhs2, 0, Stride<Dynamic, 2> > map2(buffer.data(), rhs22.rows(), rhs22.cols(),
107  Stride<Dynamic, 2>(2 * rhs22.outerStride(), 2));
108  buffer.setZero();
109  VERIFY_IS_APPROX(map2 = (rhs2) * (m2).template selfadjointView<Lower>(), rhs23 = (rhs2) * (m1));
110  }
111 }
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
void adjoint(const MatrixType &m)
Definition: adjoint.cpp:85
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Holds strides information for Map.
Definition: Stride.h:55
@ RowMajor
Definition: Constants.h:320
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
void transpose()
Definition: skew_symmetric_matrix3.cpp:135
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition: sparse_permutations.cpp:47

References adjoint(), cols, eval(), m1, m2(), Eigen::RowMajor, rows, size, anonymous_namespace{skew_symmetric_matrix3.cpp}::transpose(), VERIFY_IS_APPROX, and VERIFY_IS_EQUAL.

Referenced by cholesky(), cholesky_cplx(), EIGEN_DECLARE_TEST(), main(), matrix_l1_norm(), Eigen::AMDOrdering< StorageIndex >::operator()(), RefineablePorousChannelProblem< ELEMENT >::symmetrise_eigenfunction_for_adaptive_pitchfork_tracking(), and test_chol_update().