gtsam
3rdparty
Eigen
test
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
14
typedef
NestByValue<MatrixXd>
CpyMatrixXd
;
15
typedef
CwiseBinaryOp<internal::scalar_sum_op<double,double>
,
const
CpyMatrixXd
,
const
CpyMatrixXd
>
XprType
;
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;
31
XprType
x
=
get_xpr_with_temps
(
a
);
32
VERIFY_IS_EQUAL
(
nb_temporaries
,6);
33
MatrixXd
b
=
x
;
34
VERIFY_IS_EQUAL
(
nb_temporaries
,6+1);
35
VERIFY_IS_APPROX
(
b
,
a
.rowwise().reverse().eval() + (
a
+
a
).eval());
36
}
37
}
Eigen::CwiseBinaryOp
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition:
CwiseBinaryOp.h:77
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:386
b
Scalar * b
Definition:
benchVecAdd.cpp:17
x
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
Definition:
gnuplot_common_settings.hh:12
CpyMatrixXd
NestByValue< MatrixXd > CpyMatrixXd
Definition:
nestbyvalue.cpp:14
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(nestbyvalue)
Definition:
nestbyvalue.cpp:24
rows
int rows
Definition:
Tutorial_commainit_02.cpp:1
nb_temporaries
static long int nb_temporaries
Definition:
test/sparse_product.cpp:16
get_xpr_with_temps
XprType get_xpr_with_temps(const MatrixXd &a)
Definition:
nestbyvalue.cpp:17
Eigen::g_repeat
static int g_repeat
Definition:
main.h:169
XprType
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
Definition:
nestbyvalue.cpp:15
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition:
integer_types.cpp:15
a
ArrayXXi a
Definition:
Array_initializer_list_23_cxx11.cpp:1
main.h
EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE
Definition:
boostmultiprec.cpp:16
Eigen::NestByValue
Expression which must be nested by value.
Definition:
NestByValue.h:38
cols
int cols
Definition:
Tutorial_commainit_02.cpp:1
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition:
Meta.h:74
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:11