product_large.cpp File Reference
#include "product.h"
#include <Eigen/LU>

Functions

template<typename T >
void test_aliasing ()
 
template<int >
void product_large_regressions ()
 
template<int >
void bug_1622 ()
 
 EIGEN_DECLARE_TEST (product_large)
 

Function Documentation

◆ bug_1622()

template<int >
void bug_1622 ( )
98  {
99  typedef Matrix<double, 2, -1, 0, 2, -1> Mat2X;
100  Mat2X x(2, 2);
101  x.setRandom();
102  MatrixXd y(2, 2);
103  y.setRandom();
104  const Mat2X K1 = x * y.inverse();
105  const Matrix2d K2 = x * y.inverse();
106  VERIFY_IS_APPROX(K1, K2);
107 }
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
Scalar * y
Definition: level1_cplx_impl.h:128
list x
Definition: plotDoE.py:28

References VERIFY_IS_APPROX, plotDoE::x, and y.

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( product_large  )
109  {
110  for (int i = 0; i < g_repeat; i++) {
112  MatrixXf(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
114  MatrixXd(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
115  CALL_SUBTEST_2(product(MatrixXd(internal::random<int>(1, 10), internal::random<int>(1, 10))));
116 
118  MatrixXi(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
119  CALL_SUBTEST_4(product(MatrixXcf(internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2),
120  internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2))));
122  internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
123 
124  CALL_SUBTEST_1(test_aliasing<float>());
125 
126  CALL_SUBTEST_6(bug_1622<1>());
127 
128  CALL_SUBTEST_7(product(MatrixXcd(internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2),
129  internal::random<int>(1, EIGEN_TEST_MAX_SIZE / 2))));
131  internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
132  CALL_SUBTEST_9(product(Matrix<std::complex<float>, Dynamic, Dynamic, RowMajor>(
133  internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
134  CALL_SUBTEST_10(product(Matrix<std::complex<double>, Dynamic, Dynamic, RowMajor>(
135  internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
137  internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
138  }
139 
140  CALL_SUBTEST_6(product_large_regressions<0>());
141 
142  // Regression test for bug 714:
143 #if defined EIGEN_HAS_OPENMP
144  omp_set_dynamic(1);
145  for (int i = 0; i < g_repeat; i++) {
147  internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
148  }
149 #endif
150 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_TEST_MAX_SIZE
Definition: boostmultiprec.cpp:16
@ RowMajor
Definition: Constants.h:320
static int g_repeat
Definition: main.h:191
const int Dynamic
Definition: Constants.h:25
void product(const MatrixType &m)
Definition: product.h:42
#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_11(FUNC)
Definition: split_test_helper.h:64
#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_SUBTEST_1, CALL_SUBTEST_10, CALL_SUBTEST_11, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, CALL_SUBTEST_6, CALL_SUBTEST_7, CALL_SUBTEST_8, CALL_SUBTEST_9, Eigen::Dynamic, EIGEN_TEST_MAX_SIZE, Eigen::g_repeat, i, product(), and Eigen::RowMajor.

◆ product_large_regressions()

template<int >
void product_large_regressions ( )
38  {
39  {
40  // test a specific issue in DiagonalProduct
41  int N = 1000000;
42  VectorXf v = VectorXf::Ones(N);
43  MatrixXf m = MatrixXf::Ones(N, 3);
44  m = (v + v).asDiagonal() * m;
45  VERIFY_IS_APPROX(m, MatrixXf::Constant(N, 3, 2));
46  }
47 
48  {
49  // test deferred resizing in Matrix::operator=
50  MatrixXf a = MatrixXf::Random(10, 4), b = MatrixXf::Random(4, 10), c = a;
51  VERIFY_IS_APPROX((a = a * b), (c * b).eval());
52  }
53 
54  {
55  // check the functions to setup blocking sizes compile and do not segfault
56  // FIXME check they do what they are supposed to do !!
57  std::ptrdiff_t l1 = internal::random<int>(10000, 20000);
58  std::ptrdiff_t l2 = internal::random<int>(100000, 200000);
59  std::ptrdiff_t l3 = internal::random<int>(1000000, 2000000);
60  setCpuCacheSizes(l1, l2, l3);
61  VERIFY(l1 == l1CacheSize());
62  VERIFY(l2 == l2CacheSize());
63  std::ptrdiff_t k1 = internal::random<int>(10, 100) * 16;
64  std::ptrdiff_t m1 = internal::random<int>(10, 100) * 16;
65  std::ptrdiff_t n1 = internal::random<int>(10, 100) * 16;
66  // only makes sure it compiles fine
67  internal::computeProductBlockingSizes<float, float, std::ptrdiff_t>(k1, m1, n1, 1);
68  }
69 
70  {
71  // test regression in row-vector by matrix (bad Map type)
72  MatrixXf mat1(10, 32);
73  mat1.setRandom();
74  MatrixXf mat2(32, 32);
75  mat2.setRandom();
76  MatrixXf r1 = mat1.row(2) * mat2.transpose();
77  VERIFY_IS_APPROX(r1, (mat1.row(2) * mat2.transpose()).eval());
78 
79  MatrixXf r2 = mat1.row(2) * mat2;
80  VERIFY_IS_APPROX(r2, (mat1.row(2) * mat2).eval());
81  }
82 
83  {
84  Eigen::MatrixXd A(10, 10), B, C;
85  A.setRandom();
86  C = A;
87  for (int k = 0; k < 79; ++k) C = C * A;
88  B.noalias() =
89  (((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) *
90  ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A))) *
91  (((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) *
92  ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)) * ((A * A) * (A * A)));
94  }
95 }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Matrix3d m1
Definition: IOFormat.cpp:2
MatrixXd mat1(size, size)
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:49
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
Derived & setRandom(Index size)
Definition: Random.h:147
Definition: matrices.h:74
@ N
Definition: constructor.cpp:22
const Scalar * a
Definition: level2_cplx_impl.h:32
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
#define VERIFY(a)
Definition: main.h:362
std::ptrdiff_t l1CacheSize()
Definition: products/GeneralBlockPanelKernel.h:3119
std::ptrdiff_t l2CacheSize()
Definition: products/GeneralBlockPanelKernel.h:3127
void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2, std::ptrdiff_t l3)
Definition: products/GeneralBlockPanelKernel.h:3146
int c
Definition: calibrate.py:100
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition: sparse_permutations.cpp:47

References a, b, calibrate::c, eval(), k, Eigen::l1CacheSize(), Eigen::l2CacheSize(), m, m1, mat1(), N, Eigen::setCpuCacheSizes(), Eigen::PlainObjectBase< Derived >::setRandom(), v, VERIFY, and VERIFY_IS_APPROX.

◆ test_aliasing()

template<typename T >
void test_aliasing ( )
14  {
15  int rows = internal::random<int>(1, 12);
16  int cols = internal::random<int>(1, 12);
19  VectorType x(cols);
20  x.setRandom();
21  VectorType z(x);
22  VectorType y(rows);
23  y.setZero();
25  A.setRandom();
26  // CwiseBinaryOp
27  VERIFY_IS_APPROX(x = y + A * x, A * z); // OK because "y + A*x" is marked as "assume-aliasing"
28  x = z;
29  // CwiseUnaryOp
30  VERIFY_IS_APPROX(x = T(1.) * (A * x),
31  A * z); // OK because 1*(A*x) is replaced by (1*A*x) which is a Product<> expression
32  x = z;
33  // VERIFY_IS_APPROX(x = y-A*x, -A*z); // Not OK in 3.3 because x is resized before A*x gets evaluated
34  x = z;
35 }
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Definition: fft_test_shared.h:66

References cols, rows, Eigen::PlainObjectBase< Derived >::setRandom(), VERIFY_IS_APPROX, plotDoE::x, and y.