eigen2_mixingtypes.cpp
Go to the documentation of this file.
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 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
00006 //
00007 // Eigen is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public
00009 // License as published by the Free Software Foundation; either
00010 // version 3 of the License, or (at your option) any later version.
00011 //
00012 // Alternatively, you can redistribute it and/or
00013 // modify it under the terms of the GNU General Public License as
00014 // published by the Free Software Foundation; either version 2 of
00015 // the License, or (at your option) any later version.
00016 //
00017 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00018 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00019 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License and a copy of the GNU General Public License along with
00024 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00025 
00026 #ifndef EIGEN_NO_STATIC_ASSERT
00027 #define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them
00028 #endif
00029 
00030 #ifndef EIGEN_DONT_VECTORIZE
00031 #define EIGEN_DONT_VECTORIZE // SSE intrinsics aren't designed to allow mixing types
00032 #endif
00033 
00034 #include "main.h"
00035 
00036 
00037 template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
00038 {
00039   typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f;
00040   typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d;
00041   typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf;
00042   typedef Matrix<std::complex<double>, SizeAtCompileType, SizeAtCompileType> Mat_cd;
00043   typedef Matrix<float, SizeAtCompileType, 1> Vec_f;
00044   typedef Matrix<double, SizeAtCompileType, 1> Vec_d;
00045   typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf;
00046   typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd;
00047 
00048   Mat_f mf(size,size);
00049   Mat_d md(size,size);
00050   Mat_cf mcf(size,size);
00051   Mat_cd mcd(size,size);
00052   Vec_f vf(size,1);
00053   Vec_d vd(size,1);
00054   Vec_cf vcf(size,1);
00055   Vec_cd vcd(size,1);
00056 
00057   mf+mf;
00058   VERIFY_RAISES_ASSERT(mf+md);
00059   VERIFY_RAISES_ASSERT(mf+mcf);
00060   VERIFY_RAISES_ASSERT(vf=vd);
00061   VERIFY_RAISES_ASSERT(vf+=vd);
00062   VERIFY_RAISES_ASSERT(mcd=md);
00063 
00064   mf*mf;
00065   md*mcd;
00066   mcd*md;
00067   mf*vcf;
00068   mcf*vf;
00069   mcf *= mf;
00070   vcd = md*vcd;
00071   vcf = mcf*vf;
00072 #if 0
00073   // these are know generating hard build errors in eigen3
00074   VERIFY_RAISES_ASSERT(mf*md);
00075   VERIFY_RAISES_ASSERT(mcf*mcd);
00076   VERIFY_RAISES_ASSERT(mcf*vcd);
00077   VERIFY_RAISES_ASSERT(vcf = mf*vf);
00078 
00079   vf.eigen2_dot(vf);
00080   VERIFY_RAISES_ASSERT(vd.eigen2_dot(vf));
00081   VERIFY_RAISES_ASSERT(vcf.eigen2_dot(vf)); // yeah eventually we should allow this but i'm too lazy to make that change now in Dot.h
00082   // especially as that might be rewritten as cwise product .sum() which would make that automatic.
00083 #endif
00084 }
00085 
00086 void test_eigen2_mixingtypes()
00087 {
00088   // check that our operator new is indeed called:
00089   CALL_SUBTEST_1(mixingtypes<3>());
00090   CALL_SUBTEST_2(mixingtypes<4>());
00091   CALL_SUBTEST_3(mixingtypes<Dynamic>(20));
00092 }


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