smallvectors.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) 2006-2008 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 Scalar> void smallVectors()
00028 {
00029   typedef Matrix<Scalar, 1, 2> V2;
00030   typedef Matrix<Scalar, 3, 1> V3;
00031   typedef Matrix<Scalar, 1, 4> V4;
00032   Scalar x1 = internal::random<Scalar>(),
00033          x2 = internal::random<Scalar>(),
00034          x3 = internal::random<Scalar>(),
00035          x4 = internal::random<Scalar>();
00036   V2 v2(x1, x2);
00037   V3 v3(x1, x2, x3);
00038   V4 v4(x1, x2, x3, x4);
00039   VERIFY_IS_APPROX(x1, v2.x());
00040   VERIFY_IS_APPROX(x1, v3.x());
00041   VERIFY_IS_APPROX(x1, v4.x());
00042   VERIFY_IS_APPROX(x2, v2.y());
00043   VERIFY_IS_APPROX(x2, v3.y());
00044   VERIFY_IS_APPROX(x2, v4.y());
00045   VERIFY_IS_APPROX(x3, v3.z());
00046   VERIFY_IS_APPROX(x3, v4.z());
00047   VERIFY_IS_APPROX(x4, v4.w());
00048 }
00049 
00050 void test_smallvectors()
00051 {
00052   for(int i = 0; i < g_repeat; i++) {
00053     CALL_SUBTEST(smallVectors<int>() );
00054     CALL_SUBTEST(smallVectors<float>() );
00055     CALL_SUBTEST(smallVectors<double>() );
00056   }
00057 }


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:33:24