OLD | NEW |
(Empty) | |
| 1 // This file is part of Eigen, a lightweight C++ template library |
| 2 // for linear algebra. Eigen itself is part of the KDE project. |
| 3 // |
| 4 // Copyright (C) 2009 Keir Mierle <mierle@gmail.com> |
| 5 // |
| 6 // Eigen is free software; you can redistribute it and/or |
| 7 // modify it under the terms of the GNU Lesser General Public |
| 8 // License as published by the Free Software Foundation; either |
| 9 // version 3 of the License, or (at your option) any later version. |
| 10 // |
| 11 // Alternatively, you can redistribute it and/or |
| 12 // modify it under the terms of the GNU General Public License as |
| 13 // published by the Free Software Foundation; either version 2 of |
| 14 // the License, or (at your option) any later version. |
| 15 // |
| 16 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY |
| 17 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 18 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the |
| 19 // GNU General Public License for more details. |
| 20 // |
| 21 // You should have received a copy of the GNU Lesser General Public |
| 22 // License and a copy of the GNU General Public License along with |
| 23 // Eigen. If not, see <http://www.gnu.org/licenses/>. |
| 24 |
| 25 #include "main.h" |
| 26 |
| 27 template<int rows, int cols> |
| 28 void resizeLikeTest() |
| 29 { |
| 30 MatrixXf A(rows, cols); |
| 31 MatrixXf B; |
| 32 Matrix<double, rows, cols> C; |
| 33 B.resizeLike(A); |
| 34 C.resizeLike(B); // Shouldn't crash. |
| 35 VERIFY(B.rows() == rows && B.cols() == cols); |
| 36 |
| 37 VectorXf x(rows); |
| 38 RowVectorXf y; |
| 39 y.resizeLike(x); |
| 40 VERIFY(y.rows() == 1 && y.cols() == rows); |
| 41 |
| 42 y.resize(cols); |
| 43 x.resizeLike(y); |
| 44 VERIFY(x.rows() == cols && x.cols() == 1); |
| 45 } |
| 46 |
| 47 void resizeLikeTest12() { resizeLikeTest<1,2>(); } |
| 48 void resizeLikeTest1020() { resizeLikeTest<10,20>(); } |
| 49 void resizeLikeTest31() { resizeLikeTest<3,1>(); } |
| 50 |
| 51 void test_resize() |
| 52 { |
| 53 CALL_SUBTEST( resizeLikeTest12() ); |
| 54 CALL_SUBTEST( resizeLikeTest1020() ); |
| 55 CALL_SUBTEST( resizeLikeTest31() ); |
| 56 } |
OLD | NEW |