Home | History | Annotate | Download | only in test
      1 // This file is part of Eigen, a lightweight C++ template library
      2 // for linear algebra.
      3 //
      4 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1 (at) gmail.com>
      5 //
      6 // This Source Code Form is subject to the terms of the Mozilla
      7 // Public License v. 2.0. If a copy of the MPL was not distributed
      8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
      9 
     10 #define EIGEN_NO_STATIC_ASSERT
     11 #include "product.h"
     12 
     13 // regression test for bug 447
     14 void product1x1()
     15 {
     16   Matrix<float,1,3> matAstatic;
     17   Matrix<float,3,1> matBstatic;
     18   matAstatic.setRandom();
     19   matBstatic.setRandom();
     20   VERIFY_IS_APPROX( (matAstatic * matBstatic).coeff(0,0),
     21                     matAstatic.cwiseProduct(matBstatic.transpose()).sum() );
     22 
     23   MatrixXf matAdynamic(1,3);
     24   MatrixXf matBdynamic(3,1);
     25   matAdynamic.setRandom();
     26   matBdynamic.setRandom();
     27   VERIFY_IS_APPROX( (matAdynamic * matBdynamic).coeff(0,0),
     28                     matAdynamic.cwiseProduct(matBdynamic.transpose()).sum() );
     29 }
     30 
     31 
     32 void test_product_small()
     33 {
     34   for(int i = 0; i < g_repeat; i++) {
     35     CALL_SUBTEST_1( product(Matrix<float, 3, 2>()) );
     36     CALL_SUBTEST_2( product(Matrix<int, 3, 5>()) );
     37     CALL_SUBTEST_3( product(Matrix3d()) );
     38     CALL_SUBTEST_4( product(Matrix4d()) );
     39     CALL_SUBTEST_5( product(Matrix4f()) );
     40     CALL_SUBTEST_6( product1x1() );
     41   }
     42 
     43 #ifdef EIGEN_TEST_PART_6
     44   {
     45     // test compilation of (outer_product) * vector
     46     Vector3f v = Vector3f::Random();
     47     VERIFY_IS_APPROX( (v * v.transpose()) * v, (v * v.transpose()).eval() * v);
     48   }
     49 #endif
     50 }
     51