00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2009 Keir Mierle <mierle@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<DenseIndex rows, DenseIndex cols> 00028 void resizeLikeTest() 00029 { 00030 MatrixXf A(rows, cols); 00031 MatrixXf B; 00032 Matrix<double, rows, cols> C; 00033 B.resizeLike(A); 00034 C.resizeLike(B); // Shouldn't crash. 00035 VERIFY(B.rows() == rows && B.cols() == cols); 00036 00037 VectorXf x(rows); 00038 RowVectorXf y; 00039 y.resizeLike(x); 00040 VERIFY(y.rows() == 1 && y.cols() == rows); 00041 00042 y.resize(cols); 00043 x.resizeLike(y); 00044 VERIFY(x.rows() == cols && x.cols() == 1); 00045 } 00046 00047 void resizeLikeTest12() { resizeLikeTest<1,2>(); } 00048 void resizeLikeTest1020() { resizeLikeTest<10,20>(); } 00049 void resizeLikeTest31() { resizeLikeTest<3,1>(); } 00050 00051 void test_resize() 00052 { 00053 CALL_SUBTEST(resizeLikeTest12() ); 00054 CALL_SUBTEST(resizeLikeTest1020() ); 00055 CALL_SUBTEST(resizeLikeTest31() ); 00056 }