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) 2008 Gael Guennebaud <g.gael (at) free.fr> 5 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1 (at) gmail.com> 6 // 7 // This Source Code Form is subject to the terms of the Mozilla 8 // Public License v. 2.0. If a copy of the MPL was not distributed 9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 11 #ifndef EIGEN_NO_STATIC_ASSERT 12 #define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them 13 #endif 14 15 #ifndef EIGEN_DONT_VECTORIZE 16 #define EIGEN_DONT_VECTORIZE // SSE intrinsics aren't designed to allow mixing types 17 #endif 18 19 #include "main.h" 20 21 22 template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType) 23 { 24 typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f; 25 typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d; 26 typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf; 27 typedef Matrix<std::complex<double>, SizeAtCompileType, SizeAtCompileType> Mat_cd; 28 typedef Matrix<float, SizeAtCompileType, 1> Vec_f; 29 typedef Matrix<double, SizeAtCompileType, 1> Vec_d; 30 typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf; 31 typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd; 32 33 Mat_f mf(size,size); 34 Mat_d md(size,size); 35 Mat_cf mcf(size,size); 36 Mat_cd mcd(size,size); 37 Vec_f vf(size,1); 38 Vec_d vd(size,1); 39 Vec_cf vcf(size,1); 40 Vec_cd vcd(size,1); 41 42 mf+mf; 43 VERIFY_RAISES_ASSERT(mf+md); 44 VERIFY_RAISES_ASSERT(mf+mcf); 45 VERIFY_RAISES_ASSERT(vf=vd); 46 VERIFY_RAISES_ASSERT(vf+=vd); 47 VERIFY_RAISES_ASSERT(mcd=md); 48 49 mf*mf; 50 md*mcd; 51 mcd*md; 52 mf*vcf; 53 mcf*vf; 54 mcf *= mf; 55 vcd = md*vcd; 56 vcf = mcf*vf; 57 #if 0 58 // these are know generating hard build errors in eigen3 59 VERIFY_RAISES_ASSERT(mf*md); 60 VERIFY_RAISES_ASSERT(mcf*mcd); 61 VERIFY_RAISES_ASSERT(mcf*vcd); 62 VERIFY_RAISES_ASSERT(vcf = mf*vf); 63 64 vf.eigen2_dot(vf); 65 VERIFY_RAISES_ASSERT(vd.eigen2_dot(vf)); 66 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 67 // especially as that might be rewritten as cwise product .sum() which would make that automatic. 68 #endif 69 } 70 71 void test_eigen2_mixingtypes() 72 { 73 // check that our operator new is indeed called: 74 CALL_SUBTEST_1(mixingtypes<3>()); 75 CALL_SUBTEST_2(mixingtypes<4>()); 76 CALL_SUBTEST_3(mixingtypes<Dynamic>(20)); 77 } 78