1 // This file is part of Eigen, a lightweight C++ template library 2 // for linear algebra. 3 // 4 // Copyright (C) 2010 Hauke Heibel <hauke.heibel (at) gmail.com> 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 #include "main.h" 11 12 template <typename MatrixType> void run_nesting_ops(const MatrixType& _m) 13 { 14 typename MatrixType::Nested m(_m); 15 typedef typename MatrixType::Scalar Scalar; 16 17 #ifdef NDEBUG 18 const bool is_debug = false; 19 #else 20 const bool is_debug = true; 21 #endif 22 23 // Make really sure that we are in debug mode! We don't want any type of 24 // inlining for these tests to pass. 25 VERIFY(is_debug); 26 27 // The only intention of these tests is to ensure that this code does 28 // not trigger any asserts or segmentation faults... more to come. 29 VERIFY_IS_APPROX( (m.transpose() * m).diagonal().sum(), (m.transpose() * m).diagonal().sum() ); 30 VERIFY_IS_APPROX( (m.transpose() * m).diagonal().array().abs().sum(), (m.transpose() * m).diagonal().array().abs().sum() ); 31 32 VERIFY_IS_APPROX( (m.transpose() * m).array().abs().sum(), (m.transpose() * m).array().abs().sum() ); 33 } 34 35 void test_nesting_ops() 36 { 37 CALL_SUBTEST_1(run_nesting_ops(MatrixXf::Random(25,25))); 38 CALL_SUBTEST_2(run_nesting_ops(MatrixXd::Random(25,25))); 39 CALL_SUBTEST_3(run_nesting_ops(Matrix4f::Random())); 40 CALL_SUBTEST_4(run_nesting_ops(Matrix4d::Random())); 41 } 42