diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-11 05:06:52 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-11 05:06:52 +0000 |
commit | 19fd8cac02d060b4cf3f4b4e5125c8479aa59906 (patch) | |
tree | fb979fb4cf4f8052c8cc66b1ec9516d91fcd859b /test/nestbyvalue.cpp | |
parent | 2a5db74dcb99835414a0d2b00f0196fbe617087d (diff) | |
parent | edb0ad5bb04b48aab7dd0978f0475edd3550de7c (diff) | |
download | eigen-android13-mainline-networking-release.tar.gz |
Snap for 8570526 from edb0ad5bb04b48aab7dd0978f0475edd3550de7c to mainline-networking-releaseaml_net_331910030aml_net_331812010aml_net_331710000aml_net_331610000aml_net_331412000aml_net_331313030aml_net_331313010aml_net_331110020aml_net_331011030aml_net_330910010aml_net_330811010android13-mainline-networking-release
Change-Id: Ib5d79dcffd4079e8d0f72f2b49a2715306c8ffe2
Diffstat (limited to 'test/nestbyvalue.cpp')
-rw-r--r-- | test/nestbyvalue.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/nestbyvalue.cpp b/test/nestbyvalue.cpp new file mode 100644 index 000000000..c5356bc24 --- /dev/null +++ b/test/nestbyvalue.cpp @@ -0,0 +1,37 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2019 Gael Guennebaud <gael.guennebaud@inria.fr> +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#define TEST_ENABLE_TEMPORARY_TRACKING + +#include "main.h" + +typedef NestByValue<MatrixXd> CpyMatrixXd; +typedef CwiseBinaryOp<internal::scalar_sum_op<double,double>,const CpyMatrixXd,const CpyMatrixXd> XprType; + +XprType get_xpr_with_temps(const MatrixXd& a) +{ + MatrixXd t1 = a.rowwise().reverse(); + MatrixXd t2 = a+a; + return t1.nestByValue() + t2.nestByValue(); +} + +EIGEN_DECLARE_TEST(nestbyvalue) +{ + for(int i = 0; i < g_repeat; i++) { + Index rows = internal::random<Index>(1,EIGEN_TEST_MAX_SIZE); + Index cols = internal::random<Index>(1,EIGEN_TEST_MAX_SIZE); + MatrixXd a = MatrixXd(rows,cols); + nb_temporaries = 0; + XprType x = get_xpr_with_temps(a); + VERIFY_IS_EQUAL(nb_temporaries,6); + MatrixXd b = x; + VERIFY_IS_EQUAL(nb_temporaries,6+1); + VERIFY_IS_APPROX(b, a.rowwise().reverse().eval() + (a+a).eval()); + } +} |