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

Functions

template<typename MatrixType >
void replicate (const MatrixType &m)
 
 EIGEN_DECLARE_TEST (array_replicate)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( array_replicate  )
64  {
65  for (int i = 0; i < g_repeat; i++) {
67  CALL_SUBTEST_2(replicate(Vector2f()));
68  CALL_SUBTEST_3(replicate(Vector3d()));
69  CALL_SUBTEST_4(replicate(Vector4f()));
70  CALL_SUBTEST_5(replicate(VectorXf(16)));
71  CALL_SUBTEST_6(replicate(VectorXcd(10)));
72  }
73 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
void replicate(const MatrixType &m)
Definition: array_replicate.cpp:13
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
static int g_repeat
Definition: main.h:191
#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::g_repeat, i, and replicate().

◆ replicate()

template<typename MatrixType >
void replicate ( const MatrixType m)
13  {
14  /* this test covers the following files:
15  Replicate.cpp
16  */
17  typedef typename MatrixType::Scalar Scalar;
19  typedef Matrix<Scalar, Dynamic, Dynamic> MatrixX;
21 
22  Index rows = m.rows();
23  Index cols = m.cols();
24 
25  MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols);
26 
27  VectorType v1 = VectorType::Random(rows);
28 
29  MatrixX x1, x2;
30  VectorX vx1;
31 
32  int f1 = internal::random<int>(1, 10), f2 = internal::random<int>(1, 10);
33 
34  x1.resize(rows * f1, cols * f2);
35  for (int j = 0; j < f2; j++)
36  for (int i = 0; i < f1; i++) x1.block(i * rows, j * cols, rows, cols) = m1;
37  VERIFY_IS_APPROX(x1, m1.replicate(f1, f2));
38 
39  x2.resize(2 * rows, 3 * cols);
40  x2 << m2, m2, m2, m2, m2, m2;
41  VERIFY_IS_APPROX(x2, (m2.template replicate<2, 3>()));
42 
43  x2.resize(rows, 3 * cols);
44  x2 << m2, m2, m2;
45  VERIFY_IS_APPROX(x2, (m2.template replicate<1, 3>()));
46 
47  vx1.resize(3 * rows, cols);
48  vx1 << m2, m2, m2;
49  VERIFY_IS_APPROX(vx1 + vx1, vx1 + (m2.template replicate<3, 1>()));
50 
51  vx1 = m2 + (m2.colwise().replicate(1));
52 
53  if (m2.cols() == 1) VERIFY_IS_APPROX(m2.coeff(0), (m2.template replicate<3, 1>().coeff(m2.rows())));
54 
55  x2.resize(rows, f1);
56  for (int j = 0; j < f1; ++j) x2.col(j) = v1;
57  VERIFY_IS_APPROX(x2, v1.rowwise().replicate(f1));
58 
59  vx1.resize(rows * f2);
60  for (int j = 0; j < f2; ++j) vx1.segment(j * rows, rows) = v1;
61  VERIFY_IS_APPROX(vx1, v1.colwise().replicate(f2));
62 }
Matrix3d m1
Definition: IOFormat.cpp:2
MatrixType m2(n_dims)
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
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:294
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
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
double f2(const Vector< double > &coord)
f2 function, in front of the C2 unknown
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:233
Vector< double > x1(const Vector< double > &coord)
Cartesian coordinates centered at the point (0.5,1)
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:86
double f1(const Vector< double > &coord)
f1 function, in front of the C1 unknown
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:147
Vector< double > x2(const Vector< double > &coord)
Cartesian coordinates centered at the point (1.5,1)
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:102
Matrix< Scalar, Dynamic, 1 > VectorX
Definition: sparse_lu.cpp:43
Definition: fft_test_shared.h:66
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References cols, Global_parameters::f1(), Global_parameters::f2(), i, j, m, m1, m2(), Eigen::PlainObjectBase< Derived >::resize(), rows, v1(), VERIFY_IS_APPROX, Global_parameters::x1(), and Global_parameters::x2().

Referenced by EIGEN_DECLARE_TEST().