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 #include "product.h"
     11 
     12 void test_product_large()
     13 {
     14   for(int i = 0; i < g_repeat; i++) {
     15     CALL_SUBTEST_1( product(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
     16     CALL_SUBTEST_2( product(MatrixXd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
     17     CALL_SUBTEST_3( product(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
     18     CALL_SUBTEST_4( product(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
     19     CALL_SUBTEST_5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
     20   }
     21 
     22 #if defined EIGEN_TEST_PART_6
     23   {
     24     // test a specific issue in DiagonalProduct
     25     int N = 1000000;
     26     VectorXf v = VectorXf::Ones(N);
     27     MatrixXf m = MatrixXf::Ones(N,3);
     28     m = (v+v).asDiagonal() * m;
     29     VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2));
     30   }
     31 
     32   {
     33     // test deferred resizing in Matrix::operator=
     34     MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a;
     35     VERIFY_IS_APPROX((a = a * b), (c * b).eval());
     36   }
     37 
     38   {
     39     // check the functions to setup blocking sizes compile and do not segfault
     40     // FIXME check they do what they are supposed to do !!
     41     std::ptrdiff_t l1 = internal::random<int>(10000,20000);
     42     std::ptrdiff_t l2 = internal::random<int>(1000000,2000000);
     43     setCpuCacheSizes(l1,l2);
     44     VERIFY(l1==l1CacheSize());
     45     VERIFY(l2==l2CacheSize());
     46     std::ptrdiff_t k1 = internal::random<int>(10,100)*16;
     47     std::ptrdiff_t m1 = internal::random<int>(10,100)*16;
     48     std::ptrdiff_t n1 = internal::random<int>(10,100)*16;
     49     // only makes sure it compiles fine
     50     internal::computeProductBlockingSizes<float,float>(k1,m1,n1);
     51   }
     52 
     53   {
     54     // test regression in row-vector by matrix (bad Map type)
     55     MatrixXf mat1(10,32); mat1.setRandom();
     56     MatrixXf mat2(32,32); mat2.setRandom();
     57     MatrixXf r1 = mat1.row(2)*mat2.transpose();
     58     VERIFY_IS_APPROX(r1, (mat1.row(2)*mat2.transpose()).eval());
     59 
     60     MatrixXf r2 = mat1.row(2)*mat2;
     61     VERIFY_IS_APPROX(r2, (mat1.row(2)*mat2).eval());
     62   }
     63 #endif
     64 }
     65