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

Classes

struct  RefDerived< Ref_ >
 

Macros

#define TEST_ENABLE_TEMPORARY_TRACKING
 
#define TEST_CHECK_STATIC_ASSERTIONS
 

Typedefs

typedef Matrix< double, Dynamic, Dynamic, RowMajor > RowMatrixXd
 

Functions

template<typename MatrixType >
void ref_matrix (const MatrixType &m)
 
template<typename VectorType >
void ref_vector (const VectorType &m)
 
template<typename Scalar , int Rows, int Cols>
void ref_vector_fixed_sizes ()
 
template<typename PlainObjectType >
void check_const_correctness (const PlainObjectType &)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_1 (Ref< VectorXf > a, const B &b)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_2 (const Ref< const VectorXf > &a, const B &b)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_3 (Ref< VectorXf, 0, InnerStride<>> a, const B &b)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_4 (const Ref< const VectorXf, 0, InnerStride<>> &a, const B &b)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_5 (Ref< MatrixXf, 0, OuterStride<>> a, const B &b)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_6 (const Ref< const MatrixXf, 0, OuterStride<>> &a, const B &b)
 
template<typename B >
EIGEN_DONT_INLINE void call_ref_7 (Ref< Matrix< float, Dynamic, 3 >> a, const B &b)
 
void call_ref ()
 
int test_ref_overload_fun1 (Ref< MatrixXd >)
 
int test_ref_overload_fun1 (Ref< RowMatrixXd >)
 
int test_ref_overload_fun1 (Ref< MatrixXf >)
 
int test_ref_overload_fun2 (Ref< const MatrixXd >)
 
int test_ref_overload_fun2 (Ref< const MatrixXf >)
 
void test_ref_ambiguous (const Ref< const ArrayXd > &A, Ref< ArrayXd > B)
 
void test_ref_overloads ()
 
template<typename MatrixType , typename Derived >
void test_cref_move_ctor (const DenseBase< Derived > &expr)
 
template<typename MatrixType >
void test_contiguous_ref_no_copy (const PlainObjectBase< MatrixType > &obj)
 
 EIGEN_DECLARE_TEST (ref)
 

Macro Definition Documentation

◆ TEST_CHECK_STATIC_ASSERTIONS

#define TEST_CHECK_STATIC_ASSERTIONS

◆ TEST_ENABLE_TEMPORARY_TRACKING

#define TEST_ENABLE_TEMPORARY_TRACKING

Typedef Documentation

◆ RowMatrixXd

typedef Matrix<double, Dynamic, Dynamic, RowMajor> RowMatrixXd

Function Documentation

◆ call_ref()

void call_ref ( )
250  {
251  VectorXcf ca = VectorXcf::Random(10);
252  VectorXf a = VectorXf::Random(10);
253  RowVectorXf b = RowVectorXf::Random(10);
254  MatrixXf A = MatrixXf::Random(10, 10);
255  RowVector3f c = RowVector3f::Random();
256  const VectorXf &ac(a);
257  VectorBlock<VectorXf> ab(a, 0, 3);
258  const VectorBlock<VectorXf> abc(a, 0, 3);
259 
261  VERIFY_EVALUATION_COUNT(call_ref_1(b, b.transpose()), 0);
262  // call_ref_1(ac,a<c); // does not compile because ac is const
264  VERIFY_EVALUATION_COUNT(call_ref_1(a.head(4), a.head(4)), 0);
265  VERIFY_EVALUATION_COUNT(call_ref_1(abc, abc), 0);
266  VERIFY_EVALUATION_COUNT(call_ref_1(A.col(3), A.col(3)), 0);
267  // call_ref_1(A.row(3),A.row(3)); // does not compile because innerstride!=1
268  VERIFY_EVALUATION_COUNT(call_ref_3(A.row(3), A.row(3).transpose()), 0);
269  VERIFY_EVALUATION_COUNT(call_ref_4(A.row(3), A.row(3).transpose()), 0);
270  // call_ref_1(a+a, a+a); // does not compile for obvious reason
271 
272  MatrixXf tmp = A * A.col(1);
273  VERIFY_EVALUATION_COUNT(call_ref_2(A * A.col(1), tmp), 1); // evaluated into a temp
274  VERIFY_EVALUATION_COUNT(call_ref_2(ac.head(5), ac.head(5)), 0);
278  VERIFY_EVALUATION_COUNT(call_ref_2(a.head(4), a.head(4)), 0);
279  tmp = a + a;
280  VERIFY_EVALUATION_COUNT(call_ref_2(a + a, tmp), 1); // evaluated into a temp
281  VERIFY_EVALUATION_COUNT(call_ref_2(ca.imag(), ca.imag()), 1); // evaluated into a temp
282 
283  VERIFY_EVALUATION_COUNT(call_ref_4(ac.head(5), ac.head(5)), 0);
284  tmp = a + a;
285  VERIFY_EVALUATION_COUNT(call_ref_4(a + a, tmp), 1); // evaluated into a temp
286  VERIFY_EVALUATION_COUNT(call_ref_4(ca.imag(), ca.imag()), 0);
287 
289  VERIFY_EVALUATION_COUNT(call_ref_5(a.head(3), a.head(3)), 0);
291  // call_ref_5(A.transpose(),A.transpose()); // does not compile because storage order does not match
292  VERIFY_EVALUATION_COUNT(call_ref_5(A.block(1, 1, 2, 2), A.block(1, 1, 2, 2)), 0);
294  0); // storage order do not match, but this is a degenerate case that should work
295  VERIFY_EVALUATION_COUNT(call_ref_5(a.row(3), a.row(3)), 0);
296 
298  VERIFY_EVALUATION_COUNT(call_ref_6(a.head(3), a.head(3)), 0);
299  VERIFY_EVALUATION_COUNT(call_ref_6(A.row(3), A.row(3)),
300  1); // evaluated into a temp thouth it could be avoided by viewing it as a 1xn matrix
301  tmp = A + A;
302  VERIFY_EVALUATION_COUNT(call_ref_6(A + A, tmp), 1); // evaluated into a temp
304  VERIFY_EVALUATION_COUNT(call_ref_6(A.transpose(), A.transpose()),
305  1); // evaluated into a temp because the storage orders do not match
306  VERIFY_EVALUATION_COUNT(call_ref_6(A.block(1, 1, 2, 2), A.block(1, 1, 2, 2)), 0);
307 
309 }
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:58
const Scalar * a
Definition: level2_cplx_impl.h:32
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
int c
Definition: calibrate.py:100
EIGEN_DONT_INLINE void call_ref_6(const Ref< const MatrixXf, 0, OuterStride<>> &a, const B &b)
Definition: ref.cpp:242
EIGEN_DONT_INLINE void call_ref_4(const Ref< const VectorXf, 0, InnerStride<>> &a, const B &b)
Definition: ref.cpp:234
EIGEN_DONT_INLINE void call_ref_3(Ref< VectorXf, 0, InnerStride<>> a, const B &b)
Definition: ref.cpp:230
EIGEN_DONT_INLINE void call_ref_7(Ref< Matrix< float, Dynamic, 3 >> a, const B &b)
Definition: ref.cpp:246
EIGEN_DONT_INLINE void call_ref_2(const Ref< const VectorXf > &a, const B &b)
Definition: ref.cpp:226
EIGEN_DONT_INLINE void call_ref_5(Ref< MatrixXf, 0, OuterStride<>> a, const B &b)
Definition: ref.cpp:238
EIGEN_DONT_INLINE void call_ref_1(Ref< VectorXf > a, const B &b)
Definition: ref.cpp:222
#define VERIFY_EVALUATION_COUNT(XPR, N)
Definition: test/sparse_product.cpp:28

References a, b, calibrate::c, call_ref_1(), call_ref_2(), call_ref_3(), call_ref_4(), call_ref_5(), call_ref_6(), call_ref_7(), tmp, and VERIFY_EVALUATION_COUNT.

Referenced by EIGEN_DECLARE_TEST().

◆ call_ref_1()

template<typename B >
EIGEN_DONT_INLINE void call_ref_1 ( Ref< VectorXf >  a,
const B b 
)
222  {
223  VERIFY_IS_EQUAL(a, b);
224 }
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ call_ref_2()

template<typename B >
EIGEN_DONT_INLINE void call_ref_2 ( const Ref< const VectorXf > &  a,
const B b 
)
226  {
227  VERIFY_IS_EQUAL(a, b);
228 }

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ call_ref_3()

template<typename B >
EIGEN_DONT_INLINE void call_ref_3 ( Ref< VectorXf, 0, InnerStride<>>  a,
const B b 
)
230  {
231  VERIFY_IS_EQUAL(a, b);
232 }

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ call_ref_4()

template<typename B >
EIGEN_DONT_INLINE void call_ref_4 ( const Ref< const VectorXf, 0, InnerStride<>> &  a,
const B b 
)
234  {
235  VERIFY_IS_EQUAL(a, b);
236 }

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ call_ref_5()

template<typename B >
EIGEN_DONT_INLINE void call_ref_5 ( Ref< MatrixXf, 0, OuterStride<>>  a,
const B b 
)
238  {
239  VERIFY_IS_EQUAL(a, b);
240 }

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ call_ref_6()

template<typename B >
EIGEN_DONT_INLINE void call_ref_6 ( const Ref< const MatrixXf, 0, OuterStride<>> &  a,
const B b 
)
242  {
243  VERIFY_IS_EQUAL(a, b);
244 }

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ call_ref_7()

template<typename B >
EIGEN_DONT_INLINE void call_ref_7 ( Ref< Matrix< float, Dynamic, 3 >>  a,
const B b 
)
246  {
247  VERIFY_IS_EQUAL(a, b);
248 }

References a, b, and VERIFY_IS_EQUAL.

Referenced by call_ref().

◆ check_const_correctness()

template<typename PlainObjectType >
void check_const_correctness ( const PlainObjectType &  )
212  {
213  // verify that ref-to-const don't have LvalueBit
214  typedef std::add_const_t<PlainObjectType> ConstPlainObjectType;
215  VERIFY(!(internal::traits<Ref<ConstPlainObjectType>>::Flags & LvalueBit));
216  VERIFY(!(internal::traits<Ref<ConstPlainObjectType, Aligned>>::Flags & LvalueBit));
219 }
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:264
const unsigned int LvalueBit
Definition: Constants.h:148
#define VERIFY(a)
Definition: main.h:362
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56

References Eigen::LvalueBit, and VERIFY.

Referenced by EIGEN_DECLARE_TEST().

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( ref  )
372  {
373  for (int i = 0; i < g_repeat; i++) {
376  CALL_SUBTEST_2(ref_vector(Vector4d()));
378  CALL_SUBTEST_3(ref_vector(Vector4cf()));
379  CALL_SUBTEST_4(ref_vector(VectorXcf(8)));
380  CALL_SUBTEST_5(ref_vector(VectorXi(12)));
382 
384  CALL_SUBTEST_2(ref_matrix(Matrix4d()));
386  CALL_SUBTEST_4(ref_matrix(MatrixXcf(internal::random<int>(1, 10), internal::random<int>(1, 10))));
387  CALL_SUBTEST_4(ref_matrix(Matrix<std::complex<double>, 10, 15>()));
388  CALL_SUBTEST_5(ref_matrix(MatrixXi(internal::random<int>(1, 10), internal::random<int>(1, 10))));
390 
391  CALL_SUBTEST_8((ref_vector_fixed_sizes<float, 3, 5>()));
392  CALL_SUBTEST_8((ref_vector_fixed_sizes<float, 15, 10>()));
393  }
394 
396 
397  CALL_SUBTEST_9(test_cref_move_ctor<VectorXd>(VectorXd::Ones(9)));
398  CALL_SUBTEST_9(test_cref_move_ctor<VectorXd>(VectorXd(9)));
399  CALL_SUBTEST_9(test_cref_move_ctor<Vector3d>(Vector3d::Ones()));
400  CALL_SUBTEST_9(test_cref_move_ctor<Vector3d>(Vector3d()));
401  CALL_SUBTEST_9(test_cref_move_ctor<MatrixXd>(MatrixXd::Ones(9, 5)));
402  CALL_SUBTEST_9(test_cref_move_ctor<MatrixXd>(MatrixXd(9, 5)));
403  CALL_SUBTEST_9(test_cref_move_ctor<Matrix3d>(Matrix3d::Ones()));
404  CALL_SUBTEST_9(test_cref_move_ctor<Matrix3d>(Matrix3d()));
409 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
static int g_repeat
Definition: main.h:191
void call_ref()
Definition: ref.cpp:250
void test_ref_overloads()
Definition: ref.cpp:325
void ref_vector(const VectorType &m)
Definition: ref.cpp:80
void ref_matrix(const MatrixType &m)
Definition: ref.cpp:34
void test_contiguous_ref_no_copy(const PlainObjectBase< MatrixType > &obj)
Definition: ref.cpp:362
void check_const_correctness(const PlainObjectType &)
Definition: ref.cpp:212
#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
#define CALL_SUBTEST_9(FUNC)
Definition: split_test_helper.h:52
#define CALL_SUBTEST_10(FUNC)
Definition: split_test_helper.h:58

References call_ref(), CALL_SUBTEST_1, CALL_SUBTEST_10, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, CALL_SUBTEST_6, CALL_SUBTEST_7, CALL_SUBTEST_8, CALL_SUBTEST_9, check_const_correctness(), Eigen::g_repeat, i, ref_matrix(), ref_vector(), test_contiguous_ref_no_copy(), and test_ref_overloads().

◆ ref_matrix()

template<typename MatrixType >
void ref_matrix ( const MatrixType m)
34  {
35  typedef typename MatrixType::Scalar Scalar;
36  typedef typename MatrixType::RealScalar RealScalar;
39 
40  typedef Ref<MatrixType> RefMat;
41  typedef Ref<DynMatrixType> RefDynMat;
42  typedef Ref<const DynMatrixType> ConstRefDynMat;
43  typedef Ref<RealDynMatrixType, 0, Stride<Dynamic, Dynamic>> RefRealMatWithStride;
44 
45  Index rows = m.rows(), cols = m.cols();
46 
47  MatrixType m1 = MatrixType::Random(rows, cols), m2 = m1;
48 
49  Index i = internal::random<Index>(0, rows - 1);
50  Index j = internal::random<Index>(0, cols - 1);
51  Index brows = internal::random<Index>(1, rows - i);
52  Index bcols = internal::random<Index>(1, cols - j);
53 
54  RefMat rm0 = m1;
55  VERIFY_IS_EQUAL(rm0, m1);
56  RefDynMat rm1 = m1;
57  VERIFY_IS_EQUAL(rm1, m1);
58  RefDynMat rm2 = m1.block(i, j, brows, bcols);
59  VERIFY_IS_EQUAL(rm2, m1.block(i, j, brows, bcols));
60  rm2.setOnes();
61  m2.block(i, j, brows, bcols).setOnes();
63 
64  m2.block(i, j, brows, bcols).setRandom();
65  rm2 = m2.block(i, j, brows, bcols);
67 
68  ConstRefDynMat rm3 = m1.block(i, j, brows, bcols);
69  m1.block(i, j, brows, bcols) *= 2;
70  m2.block(i, j, brows, bcols) *= 2;
71  VERIFY_IS_EQUAL(rm3, m2.block(i, j, brows, bcols));
72  RefRealMatWithStride rm4 = m1.real();
73  VERIFY_IS_EQUAL(rm4, m2.real());
74  rm4.array() += 1;
75  m2.real().array() += 1;
77 }
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
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
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References cols, i, j, m, m1, m2(), rows, and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().

◆ ref_vector()

template<typename VectorType >
void ref_vector ( const VectorType m)
80  {
81  typedef typename VectorType::Scalar Scalar;
82  typedef typename VectorType::RealScalar RealScalar;
86 
87  typedef Ref<VectorType> RefMat;
88  typedef Ref<DynMatrixType> RefDynMat;
89  typedef Ref<const DynMatrixType> ConstRefDynMat;
90  typedef Ref<RealDynMatrixType, 0, InnerStride<>> RefRealMatWithStride;
91  typedef Ref<DynMatrixType, 0, InnerStride<>> RefMatWithStride;
92 
93  Index size = m.size();
94 
95  VectorType v1 = VectorType::Random(size), v2 = v1;
96  MatrixType mat1 = MatrixType::Random(size, size), mat2 = mat1, mat3 = MatrixType::Random(size, size);
97 
98  Index i = internal::random<Index>(0, size - 1);
99  Index bsize = internal::random<Index>(1, size - i);
100 
101  {
102  RefMat rm0 = v1;
103  VERIFY_IS_EQUAL(rm0, v1);
104  }
105  {
106  RefMat rm0 = v1.block(0, 0, size, 1);
107  VERIFY_IS_EQUAL(rm0, v1);
108  }
109  {
110  RefDynMat rv1 = v1;
111  VERIFY_IS_EQUAL(rv1, v1);
112  }
113  {
114  RefDynMat rv1 = v1.block(0, 0, size, 1);
115  VERIFY_IS_EQUAL(rv1, v1);
116  }
117 
118  RefDynMat rv2 = v1.segment(i, bsize);
119  VERIFY_IS_EQUAL(rv2, v1.segment(i, bsize));
120  rv2.setOnes();
121  v2.segment(i, bsize).setOnes();
123 
124  v2.segment(i, bsize).setRandom();
125  rv2 = v2.segment(i, bsize);
127 
128  ConstRefDynMat rm3 = v1.segment(i, bsize);
129  v1.segment(i, bsize) *= 2;
130  v2.segment(i, bsize) *= 2;
131  VERIFY_IS_EQUAL(rm3, v2.segment(i, bsize));
132 
133  RefRealMatWithStride rm4 = v1.real();
134  VERIFY_IS_EQUAL(rm4, v2.real());
135  rm4.array() += 1;
136  v2.real().array() += 1;
138 
139  RefMatWithStride rm5 = mat1.row(i).transpose();
140  VERIFY_IS_EQUAL(rm5, mat1.row(i).transpose());
141  rm5.array() += 1;
142  mat2.row(i).array() += 1;
143  VERIFY_IS_EQUAL(mat1, mat2);
144  rm5.noalias() = rm4.transpose() * mat3;
145  mat2.row(i) = v2.real().transpose() * mat3;
146  VERIFY_IS_APPROX(mat1, mat2);
147 }
MatrixXd mat1(size, size)
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
Definition: fft_test_shared.h:66

References i, m, mat1(), size, v1(), v2(), VERIFY_IS_APPROX, and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().

◆ ref_vector_fixed_sizes()

template<typename Scalar , int Rows, int Cols>
void ref_vector_fixed_sizes ( )
150  {
151  typedef Matrix<Scalar, Rows, Cols, RowMajor> RowMajorMatrixType;
152  typedef Matrix<Scalar, Rows, Cols, ColMajor> ColMajorMatrixType;
153  typedef Matrix<Scalar, 1, Cols> RowVectorType;
154  typedef Matrix<Scalar, Rows, 1> ColVectorType;
155  typedef Matrix<Scalar, Cols, 1> RowVectorTransposeType;
156  typedef Matrix<Scalar, 1, Rows> ColVectorTransposeType;
157  typedef Stride<Dynamic, Dynamic> DynamicStride;
158 
159  RowMajorMatrixType mr = RowMajorMatrixType::Random();
160  ColMajorMatrixType mc = ColMajorMatrixType::Random();
161 
162  Index i = internal::random<Index>(0, Rows - 1);
163  Index j = internal::random<Index>(0, Cols - 1);
164 
165  // Reference ith row.
166  Ref<RowVectorType, 0, DynamicStride> mr_ri = mr.row(i);
167  VERIFY_IS_EQUAL(mr_ri, mr.row(i));
168  Ref<RowVectorType, 0, DynamicStride> mc_ri = mc.row(i);
169  VERIFY_IS_EQUAL(mc_ri, mc.row(i));
170 
171  // Reference jth col.
172  Ref<ColVectorType, 0, DynamicStride> mr_cj = mr.col(j);
173  VERIFY_IS_EQUAL(mr_cj, mr.col(j));
174  Ref<ColVectorType, 0, DynamicStride> mc_cj = mc.col(j);
175  VERIFY_IS_EQUAL(mc_cj, mc.col(j));
176 
177  // Reference the transpose of row i.
179  VERIFY_IS_EQUAL(mr_rit, mr.row(i).transpose());
181  VERIFY_IS_EQUAL(mc_rit, mc.row(i).transpose());
182 
183  // Reference the transpose of col j.
185  VERIFY_IS_EQUAL(mr_cjt, mr.col(j).transpose());
187  VERIFY_IS_EQUAL(mc_cjt, mc.col(j).transpose());
188 
189  // Const references without strides.
190  Ref<const RowVectorType> cmr_ri = mr.row(i);
191  VERIFY_IS_EQUAL(cmr_ri, mr.row(i));
192  Ref<const RowVectorType> cmc_ri = mc.row(i);
193  VERIFY_IS_EQUAL(cmc_ri, mc.row(i));
194 
195  Ref<const ColVectorType> cmr_cj = mr.col(j);
196  VERIFY_IS_EQUAL(cmr_cj, mr.col(j));
197  Ref<const ColVectorType> cmc_cj = mc.col(j);
198  VERIFY_IS_EQUAL(cmc_cj, mc.col(j));
199 
200  Ref<const RowVectorTransposeType> cmr_rit = mr.row(i);
201  VERIFY_IS_EQUAL(cmr_rit, mr.row(i).transpose());
202  Ref<const RowVectorTransposeType> cmc_rit = mc.row(i);
203  VERIFY_IS_EQUAL(cmc_rit, mc.row(i).transpose());
204 
205  Ref<const ColVectorTransposeType> cmr_cjt = mr.col(j);
206  VERIFY_IS_EQUAL(cmr_cjt, mr.col(j).transpose());
207  Ref<const ColVectorTransposeType> cmc_cjt = mc.col(j);
208  VERIFY_IS_EQUAL(cmc_cjt, mc.col(j).transpose());
209 }
Holds strides information for Map.
Definition: Stride.h:55

References i, j, and VERIFY_IS_EQUAL.

◆ test_contiguous_ref_no_copy()

template<typename MatrixType >
void test_contiguous_ref_no_copy ( const PlainObjectBase< MatrixType > &  obj)
362  {
365  MatrixType m(obj);
366  Ref_ ref(m);
367  VERIFY(test_is_equal(ref.data(), m.data(), true));
368  CRef_ cref(m);
369  VERIFY(test_is_equal(cref.data(), m.data(), true));
370 }
bool test_is_equal(const T &actual, const U &expected, bool expect_equal)
Definition: main.h:688

References m, Eigen::test_is_equal(), and VERIFY.

Referenced by EIGEN_DECLARE_TEST().

◆ test_cref_move_ctor()

template<typename MatrixType , typename Derived >
void test_cref_move_ctor ( const DenseBase< Derived > &  expr)
346  {
347  typedef Ref<const MatrixType> CRef;
348  typedef RefDerived<CRef> CRefDerived;
349 
350  const bool owns_data = !bool(internal::traits<CRef>::template match<Derived>::type::value);
351  CRef cref1(expr);
352  const double *data1 = cref1.data(), *obj_data1 = static_cast<CRefDerived &>(cref1).m_object.data();
353  VERIFY(test_is_equal(data1, obj_data1, owns_data));
354  CRef cref2(std::move(cref1));
355  VERIFY_IS_EQUAL(data1, cref1.data());
356  const double *data2 = cref2.data(), *obj_data2 = static_cast<CRefDerived &>(cref2).m_object.data();
357  VERIFY(test_is_equal(data1, data2, MatrixType::MaxSizeAtCompileTime == Dynamic || !owns_data));
358  VERIFY(test_is_equal(data1, obj_data2, MatrixType::MaxSizeAtCompileTime == Dynamic && owns_data));
359 }
squared absolute value
Definition: GlobalFunctions.h:87
const int Dynamic
Definition: Constants.h:25
Definition: ref.cpp:341

References Eigen::Dynamic, Eigen::test_is_equal(), Eigen::value, VERIFY, and VERIFY_IS_EQUAL.

◆ test_ref_ambiguous()

void test_ref_ambiguous ( const Ref< const ArrayXd > &  A,
Ref< ArrayXd >  B 
)
319  {
320  B = A;
321  B = A - A;
322 }
Definition: matrices.h:74

Referenced by test_ref_overloads().

◆ test_ref_overload_fun1() [1/3]

int test_ref_overload_fun1 ( Ref< MatrixXd >  )
312 { return 1; }

Referenced by test_ref_overloads().

◆ test_ref_overload_fun1() [2/3]

int test_ref_overload_fun1 ( Ref< MatrixXf >  )
314 { return 3; }

◆ test_ref_overload_fun1() [3/3]

int test_ref_overload_fun1 ( Ref< RowMatrixXd )
313 { return 2; }

◆ test_ref_overload_fun2() [1/2]

int test_ref_overload_fun2 ( Ref< const MatrixXd >  )
316 { return 4; }

Referenced by test_ref_overloads().

◆ test_ref_overload_fun2() [2/2]

int test_ref_overload_fun2 ( Ref< const MatrixXf >  )
317 { return 5; }

◆ test_ref_overloads()

void test_ref_overloads ( )
325  {
326  MatrixXd Ad, Bd;
327  RowMatrixXd rAd, rBd;
328  VERIFY(test_ref_overload_fun1(Ad) == 1);
329  VERIFY(test_ref_overload_fun1(rAd) == 2);
330 
331  MatrixXf Af, Bf;
332  VERIFY(test_ref_overload_fun2(Ad) == 4);
333  VERIFY(test_ref_overload_fun2(Ad + Bd) == 4);
334  VERIFY(test_ref_overload_fun2(Af + Bf) == 5);
335 
336  ArrayXd A, B;
338 }
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
void test_ref_ambiguous(const Ref< const ArrayXd > &A, Ref< ArrayXd > B)
Definition: ref.cpp:319
int test_ref_overload_fun1(Ref< MatrixXd >)
Definition: ref.cpp:312
int test_ref_overload_fun2(Ref< const MatrixXd >)
Definition: ref.cpp:316

References test_ref_ambiguous(), test_ref_overload_fun1(), test_ref_overload_fun2(), and VERIFY.

Referenced by EIGEN_DECLARE_TEST().