nesting_ops.cpp
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #include "main.h"
00026 
00027 template <typename MatrixType> void run_nesting_ops(const MatrixType& _m)
00028 {
00029   typename MatrixType::Nested m(_m);
00030   typedef typename MatrixType::Scalar Scalar;
00031 
00032 #ifdef NDEBUG
00033   const bool is_debug = false;
00034 #else
00035   const bool is_debug = true;
00036 #endif
00037 
00038   // Make really sure that we are in debug mode! We don't want any type of
00039   // inlining for these tests to pass.
00040   VERIFY(is_debug);
00041 
00042   // The only intention of these tests is to ensure that this code does
00043   // not trigger any asserts or segmentation faults... more to come.
00044   VERIFY_IS_APPROX( (m.transpose() * m).diagonal().sum(), (m.transpose() * m).diagonal().sum() );
00045   VERIFY_IS_APPROX( (m.transpose() * m).diagonal().array().abs().sum(), (m.transpose() * m).diagonal().array().abs().sum() );
00046 
00047   VERIFY_IS_APPROX( (m.transpose() * m).array().abs().sum(), (m.transpose() * m).array().abs().sum() );
00048 }
00049 
00050 void test_nesting_ops()
00051 {
00052   CALL_SUBTEST_1(run_nesting_ops(MatrixXf::Random(25,25)));
00053   CALL_SUBTEST_2(run_nesting_ops(MatrixXd::Random(25,25)));
00054   CALL_SUBTEST_3(run_nesting_ops(Matrix4f::Random()));
00055   CALL_SUBTEST_4(run_nesting_ops(Matrix4d::Random()));
00056 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:00