alignedvector3.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) 2009 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 #include <unsupported/Eigen/AlignedVector3>
00027 
00028 template<typename Scalar>
00029 void alignedvector3()
00030 {
00031   Scalar s1 = internal::random<Scalar>();
00032   Scalar s2 = internal::random<Scalar>();
00033   typedef Matrix<Scalar,3,1> RefType;
00034   typedef Matrix<Scalar,3,3> Mat33;
00035   typedef AlignedVector3<Scalar> FastType;
00036   RefType  r1(RefType::Random()), r2(RefType::Random()), r3(RefType::Random()),
00037            r4(RefType::Random()), r5(RefType::Random()), r6(RefType::Random());
00038   FastType f1(r1), f2(r2), f3(r3), f4(r4), f5(r5), f6(r6);
00039   Mat33 m1(Mat33::Random());
00040   
00041   VERIFY_IS_APPROX(f1,r1);
00042   VERIFY_IS_APPROX(f4,r4);
00043 
00044   VERIFY_IS_APPROX(f4+f1,r4+r1);
00045   VERIFY_IS_APPROX(f4-f1,r4-r1);
00046   VERIFY_IS_APPROX(f4+f1-f2,r4+r1-r2);
00047   VERIFY_IS_APPROX(f4+=f3,r4+=r3);
00048   VERIFY_IS_APPROX(f4-=f5,r4-=r5);
00049   VERIFY_IS_APPROX(f4-=f5+f1,r4-=r5+r1);
00050   VERIFY_IS_APPROX(f5+f1-s1*f2,r5+r1-s1*r2);
00051   VERIFY_IS_APPROX(f5+f1/s2-s1*f2,r5+r1/s2-s1*r2);
00052   
00053   VERIFY_IS_APPROX(m1*f4,m1*r4);
00054   VERIFY_IS_APPROX(f4.transpose()*m1,r4.transpose()*m1);
00055   
00056   VERIFY_IS_APPROX(f2.dot(f3),r2.dot(r3));
00057   VERIFY_IS_APPROX(f2.cross(f3),r2.cross(r3));
00058   VERIFY_IS_APPROX(f2.norm(),r2.norm());
00059 
00060   VERIFY_IS_APPROX(f2.normalized(),r2.normalized());
00061 
00062   VERIFY_IS_APPROX((f2+f1).normalized(),(r2+r1).normalized());
00063   
00064   f2.normalize();
00065   r2.normalize();
00066   VERIFY_IS_APPROX(f2,r2);
00067 }
00068 
00069 void test_alignedvector3()
00070 {
00071   for(int i = 0; i < g_repeat; i++) {
00072     CALL_SUBTEST( alignedvector3<float>() );
00073   }
00074 }


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