nestbyvalue.cpp
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2019 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #define TEST_ENABLE_TEMPORARY_TRACKING
11 
12 #include "main.h"
13 
16 
17 XprType get_xpr_with_temps(const MatrixXd& a)
18 {
19  MatrixXd t1 = a.rowwise().reverse();
20  MatrixXd t2 = a+a;
21  return t1.nestByValue() + t2.nestByValue();
22 }
23 
24 EIGEN_DECLARE_TEST(nestbyvalue)
25 {
26  for(int i = 0; i < g_repeat; i++) {
27  Index rows = internal::random<Index>(1,EIGEN_TEST_MAX_SIZE);
28  Index cols = internal::random<Index>(1,EIGEN_TEST_MAX_SIZE);
29  MatrixXd a = MatrixXd(rows,cols);
30  nb_temporaries = 0;
33  MatrixXd b = x;
35  VERIFY_IS_APPROX(b, a.rowwise().reverse().eval() + (a+a).eval());
36  }
37 }
Scalar * b
Definition: benchVecAdd.cpp:17
static long int nb_temporaries
#define VERIFY_IS_APPROX(a, b)
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:386
static int g_repeat
Definition: main.h:169
NestByValue< MatrixXd > CpyMatrixXd
Definition: nestbyvalue.cpp:14
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Expression which must be nested by value.
Definition: NestByValue.h:38
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
Definition: nestbyvalue.cpp:15
#define EIGEN_TEST_MAX_SIZE
XprType get_xpr_with_temps(const MatrixXd &a)
Definition: nestbyvalue.cpp:17
internal::nested_eval< T, 1 >::type eval(const T &xpr)
EIGEN_DECLARE_TEST(nestbyvalue)
Definition: nestbyvalue.cpp:24
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:56