eigen2_sizeof.cpp
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra. Eigen itself is part of the KDE project.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
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 verifySizeOf(const MatrixType&)
00028 {
00029   typedef typename MatrixType::Scalar Scalar;
00030   if (MatrixType::RowsAtCompileTime!=Dynamic && MatrixType::ColsAtCompileTime!=Dynamic)
00031     VERIFY(sizeof(MatrixType)==sizeof(Scalar)*MatrixType::SizeAtCompileTime);
00032   else
00033     VERIFY(sizeof(MatrixType)==sizeof(Scalar*) + 2 * sizeof(typename MatrixType::Index));
00034 }
00035 
00036 void test_eigen2_sizeof()
00037 {
00038   CALL_SUBTEST( verifySizeOf(Matrix<float, 1, 1>()) );
00039   CALL_SUBTEST( verifySizeOf(Matrix4d()) );
00040   CALL_SUBTEST( verifySizeOf(Matrix<double, 4, 2>()) );
00041   CALL_SUBTEST( verifySizeOf(Matrix<bool, 7, 5>()) );
00042   CALL_SUBTEST( verifySizeOf(MatrixXcf(3, 3)) );
00043   CALL_SUBTEST( verifySizeOf(MatrixXi(8, 12)) );
00044   CALL_SUBTEST( verifySizeOf(MatrixXcd(20, 20)) );
00045   CALL_SUBTEST( verifySizeOf(Matrix<float, 100, 100>()) );
00046 }


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