From 192bce2795bbfaa0d4e6fdcd270a95d59da82f66 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 10 Jun 2015 10:09:04 +0200 Subject: bug #890, add a more general routine to check that two dense object reference to the same data --- test/is_same_dense.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/is_same_dense.cpp (limited to 'test/is_same_dense.cpp') diff --git a/test/is_same_dense.cpp b/test/is_same_dense.cpp new file mode 100644 index 000000000..318ba8717 --- /dev/null +++ b/test/is_same_dense.cpp @@ -0,0 +1,30 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2015 Gael Guennebaud +// +// 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/. + +#include "main.h" + +void test_is_same_dense() +{ + MatrixXd m1(10,10); + Ref ref_m1(m1); + Ref const_ref_m1(m1); + VERIFY(is_same_dense(m1,m1)); + VERIFY(is_same_dense(m1,ref_m1)); + VERIFY(is_same_dense(const_ref_m1,m1)); + VERIFY(is_same_dense(const_ref_m1,ref_m1)); + + VERIFY(is_same_dense(m1.block(0,0,m1.rows(),m1.cols()),m1)); + VERIFY(!is_same_dense(m1.row(0),m1.col(0))); + + Ref const_ref_m1_row(m1.row(1)); + VERIFY(!is_same_dense(m1.row(1),const_ref_m1_row)); + + Ref const_ref_m1_col(m1.col(1)); + VERIFY(is_same_dense(m1.col(1),const_ref_m1_col)); +} -- cgit v1.2.3