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 void test_eigen2_commainitializer() 00028 { 00029 Matrix3d m3; 00030 Matrix4d m4; 00031 00032 VERIFY_RAISES_ASSERT( (m3 << 1, 2, 3, 4, 5, 6, 7, 8) ); 00033 00034 #ifndef _MSC_VER 00035 VERIFY_RAISES_ASSERT( (m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) ); 00036 #endif 00037 00038 double data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; 00039 Matrix3d ref = Map<Matrix<double,3,3,RowMajor> >(data); 00040 00041 m3 = Matrix3d::Random(); 00042 m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9; 00043 VERIFY_IS_APPROX(m3, ref ); 00044 00045 Vector3d vec[3]; 00046 vec[0] << 1, 4, 7; 00047 vec[1] << 2, 5, 8; 00048 vec[2] << 3, 6, 9; 00049 m3 = Matrix3d::Random(); 00050 m3 << vec[0], vec[1], vec[2]; 00051 VERIFY_IS_APPROX(m3, ref); 00052 00053 vec[0] << 1, 2, 3; 00054 vec[1] << 4, 5, 6; 00055 vec[2] << 7, 8, 9; 00056 m3 = Matrix3d::Random(); 00057 m3 << vec[0].transpose(), 00058 4, 5, 6, 00059 vec[2].transpose(); 00060 VERIFY_IS_APPROX(m3, ref); 00061 }