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

Functions

template<typename MatrixType >
void trmv (const MatrixType &m)
 
 EIGEN_DECLARE_TEST (product_trmv)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( product_trmv  )
76  {
77  int s = 0;
78  for (int i = 0; i < g_repeat; i++) {
81  CALL_SUBTEST_3(trmv(Matrix3d()));
82 
83  s = internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2);
84  CALL_SUBTEST_4(trmv(MatrixXcf(s, s)));
85  CALL_SUBTEST_5(trmv(MatrixXcd(s, s)));
87 
88  s = internal::random<int>(1, EIGEN_TEST_MAX_SIZE);
91  }
92 }
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 trmv(const MatrixType &m)
Definition: product_trmv.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_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 CALL_SUBTEST_1, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, CALL_SUBTEST_6, EIGEN_TEST_MAX_SIZE, Eigen::g_repeat, i, s, TEST_SET_BUT_UNUSED_VARIABLE, and trmv().

◆ trmv()

template<typename MatrixType >
void trmv ( const MatrixType m)
13  {
14  typedef typename MatrixType::Scalar Scalar;
15  typedef typename NumTraits<Scalar>::Real RealScalar;
17 
18  RealScalar largerEps = 10 * test_precision<RealScalar>();
19 
20  Index rows = m.rows();
21  Index cols = m.cols();
22 
23  MatrixType m1 = MatrixType::Random(rows, cols), m3(rows, cols);
24  VectorType v1 = VectorType::Random(rows);
25 
26  Scalar s1 = internal::random<Scalar>();
27 
28  m1 = MatrixType::Random(rows, cols);
29 
30  // check with a column-major matrix
31  m3 = m1.template triangularView<Eigen::Lower>();
32  VERIFY((m3 * v1).isApprox(m1.template triangularView<Eigen::Lower>() * v1, largerEps));
33  m3 = m1.template triangularView<Eigen::Upper>();
34  VERIFY((m3 * v1).isApprox(m1.template triangularView<Eigen::Upper>() * v1, largerEps));
35  m3 = m1.template triangularView<Eigen::UnitLower>();
36  VERIFY((m3 * v1).isApprox(m1.template triangularView<Eigen::UnitLower>() * v1, largerEps));
37  m3 = m1.template triangularView<Eigen::UnitUpper>();
38  VERIFY((m3 * v1).isApprox(m1.template triangularView<Eigen::UnitUpper>() * v1, largerEps));
39 
40  // check conjugated and scalar multiple expressions (col-major)
41  m3 = m1.template triangularView<Eigen::Lower>();
42  VERIFY(((s1 * m3).conjugate() * v1)
43  .isApprox((s1 * m1).conjugate().template triangularView<Eigen::Lower>() * v1, largerEps));
44  m3 = m1.template triangularView<Eigen::Upper>();
45  VERIFY((m3.conjugate() * v1.conjugate())
46  .isApprox(m1.conjugate().template triangularView<Eigen::Upper>() * v1.conjugate(), largerEps));
47 
48  // check with a row-major matrix
49  m3 = m1.template triangularView<Eigen::Upper>();
50  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView<Eigen::Lower>() * v1, largerEps));
51  m3 = m1.template triangularView<Eigen::Lower>();
52  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView<Eigen::Upper>() * v1, largerEps));
53  m3 = m1.template triangularView<Eigen::UnitUpper>();
54  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView<Eigen::UnitLower>() * v1, largerEps));
55  m3 = m1.template triangularView<Eigen::UnitLower>();
56  VERIFY((m3.transpose() * v1).isApprox(m1.transpose().template triangularView<Eigen::UnitUpper>() * v1, largerEps));
57 
58  // check conjugated and scalar multiple expressions (row-major)
59  m3 = m1.template triangularView<Eigen::Upper>();
60  VERIFY((m3.adjoint() * v1).isApprox(m1.adjoint().template triangularView<Eigen::Lower>() * v1, largerEps));
61  m3 = m1.template triangularView<Eigen::Lower>();
62  VERIFY((m3.adjoint() * (s1 * v1.conjugate()))
63  .isApprox(m1.adjoint().template triangularView<Eigen::Upper>() * (s1 * v1.conjugate()), largerEps));
64  m3 = m1.template triangularView<Eigen::UnitUpper>();
65 
66  // check transposed cases:
67  m3 = m1.template triangularView<Eigen::Lower>();
68  VERIFY((v1.transpose() * m3).isApprox(v1.transpose() * m1.template triangularView<Eigen::Lower>(), largerEps));
69  VERIFY((v1.adjoint() * m3).isApprox(v1.adjoint() * m1.template triangularView<Eigen::Lower>(), largerEps));
70  VERIFY((v1.adjoint() * m3.adjoint())
71  .isApprox(v1.adjoint() * m1.template triangularView<Eigen::Lower>().adjoint(), largerEps));
72 
73  // TODO check with sub-matrices
74 }
Matrix3d m1
Definition: IOFormat.cpp:2
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
int * m
Definition: level2_cplx_impl.h:294
#define VERIFY(a)
Definition: main.h:362
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1923
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: fft_test_shared.h:66

References cols, Eigen::internal::isApprox(), m, m1, rows, v1(), and VERIFY.

Referenced by EIGEN_DECLARE_TEST().