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

Macros

#define COMPARE_CORNER(A, B)
 

Functions

template<typename MatrixType >
void corners (const MatrixType &m)
 
template<typename MatrixType , int CRows, int CCols, int SRows, int SCols>
void corners_fixedsize ()
 
 EIGEN_DECLARE_TEST (corners)
 

Macro Definition Documentation

◆ COMPARE_CORNER

#define COMPARE_CORNER (   A,
  B 
)
Value:
VERIFY_IS_EQUAL(const_matrix.A, const_matrix.B);
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367

Function Documentation

◆ corners()

template<typename MatrixType >
void corners ( const MatrixType m)
17  {
18  Index rows = m.rows();
19  Index cols = m.cols();
20 
21  Index r = internal::random<Index>(1, rows);
22  Index c = internal::random<Index>(1, cols);
23 
24  MatrixType matrix = MatrixType::Random(rows, cols);
25  const MatrixType const_matrix = MatrixType::Random(rows, cols);
26 
27  COMPARE_CORNER(topLeftCorner(r, c), block(0, 0, r, c));
31 
32  Index sr = internal::random<Index>(1, rows) - 1;
33  Index nr = internal::random<Index>(1, rows - sr);
34  Index sc = internal::random<Index>(1, cols) - 1;
35  Index nc = internal::random<Index>(1, cols - sc);
36 
37  COMPARE_CORNER(topRows(r), block(0, 0, r, cols));
38  COMPARE_CORNER(middleRows(sr, nr), block(sr, 0, nr, cols));
39  COMPARE_CORNER(bottomRows(r), block(rows - r, 0, r, cols));
40  COMPARE_CORNER(leftCols(c), block(0, 0, rows, c));
41  COMPARE_CORNER(middleCols(sc, nc), block(0, sc, rows, nc));
42  COMPARE_CORNER(rightCols(c), block(0, cols - c, rows, c));
43 }
mat1 bottomLeftCorner(size/2, size/2)
mat1 topRightCorner(size/2, size/2)
mat1 bottomRightCorner(size/2, size/2)
m m block(1, 0, 2, 2)<< 4
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Eigen::Block< Derived > topLeftCorner(Eigen::MatrixBase< Derived > &m, int rows, int cols)
Definition: class_Block.cpp:5
#define COMPARE_CORNER(A, B)
Definition: corners.cpp:12
int * m
Definition: level2_cplx_impl.h:294
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
r
Definition: UniformPSDSelfTest.py:20
int c
Definition: calibrate.py:100

References block(), bottomLeftCorner(), bottomRightCorner(), calibrate::c, cols, COMPARE_CORNER, m, matrix(), UniformPSDSelfTest::r, rows, topLeftCorner(), and topRightCorner().

Referenced by alignedboxNonIntegralRotatable(), EIGEN_DECLARE_TEST(), check_sqrt_impl< std::complex< T > >::run(), check_rsqrt_impl< std::complex< T > >::run(), and TriangleMeshWall::updateBoundingBoxGlobal().

◆ corners_fixedsize()

template<typename MatrixType , int CRows, int CCols, int SRows, int SCols>
void corners_fixedsize ( )
46  {
47  MatrixType matrix = MatrixType::Random();
48  const MatrixType const_matrix = MatrixType::Random();
49 
50  enum {
51  rows = MatrixType::RowsAtCompileTime,
52  cols = MatrixType::ColsAtCompileTime,
53  r = CRows,
54  c = CCols,
55  sr = SRows,
56  sc = SCols
57  };
58 
59  VERIFY_IS_EQUAL((matrix.template topLeftCorner<r, c>()), (matrix.template block<r, c>(0, 0)));
60  VERIFY_IS_EQUAL((matrix.template topRightCorner<r, c>()), (matrix.template block<r, c>(0, cols - c)));
61  VERIFY_IS_EQUAL((matrix.template bottomLeftCorner<r, c>()), (matrix.template block<r, c>(rows - r, 0)));
62  VERIFY_IS_EQUAL((matrix.template bottomRightCorner<r, c>()), (matrix.template block<r, c>(rows - r, cols - c)));
63 
64  VERIFY_IS_EQUAL((matrix.template topLeftCorner<r, c>()), (matrix.template topLeftCorner<r, Dynamic>(r, c)));
65  VERIFY_IS_EQUAL((matrix.template topRightCorner<r, c>()), (matrix.template topRightCorner<r, Dynamic>(r, c)));
66  VERIFY_IS_EQUAL((matrix.template bottomLeftCorner<r, c>()), (matrix.template bottomLeftCorner<r, Dynamic>(r, c)));
67  VERIFY_IS_EQUAL((matrix.template bottomRightCorner<r, c>()), (matrix.template bottomRightCorner<r, Dynamic>(r, c)));
68 
69  VERIFY_IS_EQUAL((matrix.template topLeftCorner<r, c>()), (matrix.template topLeftCorner<Dynamic, c>(r, c)));
70  VERIFY_IS_EQUAL((matrix.template topRightCorner<r, c>()), (matrix.template topRightCorner<Dynamic, c>(r, c)));
71  VERIFY_IS_EQUAL((matrix.template bottomLeftCorner<r, c>()), (matrix.template bottomLeftCorner<Dynamic, c>(r, c)));
72  VERIFY_IS_EQUAL((matrix.template bottomRightCorner<r, c>()), (matrix.template bottomRightCorner<Dynamic, c>(r, c)));
73 
74  VERIFY_IS_EQUAL((matrix.template topRows<r>()), (matrix.template block<r, cols>(0, 0)));
75  VERIFY_IS_EQUAL((matrix.template middleRows<r>(sr)), (matrix.template block<r, cols>(sr, 0)));
76  VERIFY_IS_EQUAL((matrix.template bottomRows<r>()), (matrix.template block<r, cols>(rows - r, 0)));
77  VERIFY_IS_EQUAL((matrix.template leftCols<c>()), (matrix.template block<rows, c>(0, 0)));
78  VERIFY_IS_EQUAL((matrix.template middleCols<c>(sc)), (matrix.template block<rows, c>(0, sc)));
79  VERIFY_IS_EQUAL((matrix.template rightCols<c>()), (matrix.template block<rows, c>(0, cols - c)));
80 
81  VERIFY_IS_EQUAL((const_matrix.template topLeftCorner<r, c>()), (const_matrix.template block<r, c>(0, 0)));
82  VERIFY_IS_EQUAL((const_matrix.template topRightCorner<r, c>()), (const_matrix.template block<r, c>(0, cols - c)));
83  VERIFY_IS_EQUAL((const_matrix.template bottomLeftCorner<r, c>()), (const_matrix.template block<r, c>(rows - r, 0)));
84  VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner<r, c>()),
85  (const_matrix.template block<r, c>(rows - r, cols - c)));
86 
87  VERIFY_IS_EQUAL((const_matrix.template topLeftCorner<r, c>()),
88  (const_matrix.template topLeftCorner<r, Dynamic>(r, c)));
89  VERIFY_IS_EQUAL((const_matrix.template topRightCorner<r, c>()),
90  (const_matrix.template topRightCorner<r, Dynamic>(r, c)));
91  VERIFY_IS_EQUAL((const_matrix.template bottomLeftCorner<r, c>()),
92  (const_matrix.template bottomLeftCorner<r, Dynamic>(r, c)));
93  VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner<r, c>()),
94  (const_matrix.template bottomRightCorner<r, Dynamic>(r, c)));
95 
96  VERIFY_IS_EQUAL((const_matrix.template topLeftCorner<r, c>()),
97  (const_matrix.template topLeftCorner<Dynamic, c>(r, c)));
98  VERIFY_IS_EQUAL((const_matrix.template topRightCorner<r, c>()),
99  (const_matrix.template topRightCorner<Dynamic, c>(r, c)));
100  VERIFY_IS_EQUAL((const_matrix.template bottomLeftCorner<r, c>()),
101  (const_matrix.template bottomLeftCorner<Dynamic, c>(r, c)));
102  VERIFY_IS_EQUAL((const_matrix.template bottomRightCorner<r, c>()),
103  (const_matrix.template bottomRightCorner<Dynamic, c>(r, c)));
104 
105  VERIFY_IS_EQUAL((const_matrix.template topRows<r>()), (const_matrix.template block<r, cols>(0, 0)));
106  VERIFY_IS_EQUAL((const_matrix.template middleRows<r>(sr)), (const_matrix.template block<r, cols>(sr, 0)));
107  VERIFY_IS_EQUAL((const_matrix.template bottomRows<r>()), (const_matrix.template block<r, cols>(rows - r, 0)));
108  VERIFY_IS_EQUAL((const_matrix.template leftCols<c>()), (const_matrix.template block<rows, c>(0, 0)));
109  VERIFY_IS_EQUAL((const_matrix.template middleCols<c>(sc)), (const_matrix.template block<rows, c>(0, sc)));
110  VERIFY_IS_EQUAL((const_matrix.template rightCols<c>()), (const_matrix.template block<rows, c>(0, cols - c)));
111 }

References calibrate::c, cols, matrix(), UniformPSDSelfTest::r, rows, and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( corners  )
113  {
114  for (int i = 0; i < g_repeat; i++) {
116  CALL_SUBTEST_2(corners(Matrix4d()));
118  CALL_SUBTEST_4(corners(MatrixXcf(5, 7)));
119  CALL_SUBTEST_5(corners(MatrixXf(21, 20)));
120 
122  CALL_SUBTEST_2((corners_fixedsize<Matrix4d, 2, 2, 1, 1>()));
124  }
125 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
void corners(const MatrixType &m)
Definition: corners.cpp:17
void corners_fixedsize()
Definition: corners.cpp:46
static int g_repeat
Definition: main.h:191
#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, corners(), corners_fixedsize(), Eigen::g_repeat, and i.