zerosized.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) 2011 Benoit Jacob <jacob.benoit.1@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 zeroSizedMatrix()
00028 {
00029   MatrixType t1;
00030 
00031   if (MatrixType::SizeAtCompileTime == Dynamic)
00032   {
00033     if (MatrixType::RowsAtCompileTime == Dynamic)
00034       VERIFY(t1.rows() == 0);
00035     if (MatrixType::ColsAtCompileTime == Dynamic)
00036       VERIFY(t1.cols() == 0);
00037 
00038     if (MatrixType::RowsAtCompileTime == Dynamic && MatrixType::ColsAtCompileTime == Dynamic)
00039     {
00040       MatrixType t2(0, 0);
00041       VERIFY(t2.rows() == 0);
00042       VERIFY(t2.cols() == 0);
00043     }
00044   }
00045 }
00046 
00047 template<typename VectorType> void zeroSizedVector()
00048 {
00049   VectorType t1;
00050 
00051   if (VectorType::SizeAtCompileTime == Dynamic)
00052   {
00053     VERIFY(t1.size() == 0);
00054     VectorType t2(DenseIndex(0)); // DenseIndex disambiguates with 0-the-null-pointer (error with gcc 4.4 and MSVC8)
00055     VERIFY(t2.size() == 0);
00056   }
00057 }
00058 
00059 void test_zerosized()
00060 {
00061   zeroSizedMatrix<Matrix2d>();
00062   zeroSizedMatrix<Matrix3i>();
00063   zeroSizedMatrix<Matrix<float, 2, Dynamic> >();
00064   zeroSizedMatrix<MatrixXf>();
00065   
00066   zeroSizedVector<Vector2d>();
00067   zeroSizedVector<Vector3i>();
00068   zeroSizedVector<VectorXf>();
00069 }


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