2008-08-02 07:44:59 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-23 02:25:33 +08:00
|
|
|
// for linear algebra.
|
2008-08-02 07:44:59 +08:00
|
|
|
//
|
2008-11-24 21:40:43 +08:00
|
|
|
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
2008-08-02 07:44:59 +08:00
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2008-08-02 07:44:59 +08:00
|
|
|
|
|
|
|
#include "product.h"
|
|
|
|
|
|
|
|
void test_product_large()
|
|
|
|
{
|
|
|
|
for(int i = 0; i < g_repeat; i++) {
|
2011-07-12 20:41:00 +08:00
|
|
|
CALL_SUBTEST_1( product(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
|
|
|
CALL_SUBTEST_2( product(MatrixXd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
|
|
|
CALL_SUBTEST_3( product(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
|
|
|
CALL_SUBTEST_4( product(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
|
|
|
|
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))) );
|
2008-08-02 07:44:59 +08:00
|
|
|
}
|
2008-12-11 03:02:13 +08:00
|
|
|
|
2009-10-20 02:40:35 +08:00
|
|
|
#if defined EIGEN_TEST_PART_6
|
2008-12-11 03:02:13 +08:00
|
|
|
{
|
|
|
|
// test a specific issue in DiagonalProduct
|
|
|
|
int N = 1000000;
|
|
|
|
VectorXf v = VectorXf::Ones(N);
|
|
|
|
MatrixXf m = MatrixXf::Ones(N,3);
|
|
|
|
m = (v+v).asDiagonal() * m;
|
|
|
|
VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2));
|
|
|
|
}
|
2009-07-20 16:35:47 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
// test deferred resizing in Matrix::operator=
|
|
|
|
MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a;
|
|
|
|
VERIFY_IS_APPROX((a = a * b), (c * b).eval());
|
|
|
|
}
|
2010-06-11 04:11:31 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
// check the functions to setup blocking sizes compile and do not segfault
|
|
|
|
// FIXME check they do what they are supposed to do !!
|
2010-10-25 22:15:22 +08:00
|
|
|
std::ptrdiff_t l1 = internal::random<int>(10000,20000);
|
|
|
|
std::ptrdiff_t l2 = internal::random<int>(1000000,2000000);
|
2010-06-11 04:11:31 +08:00
|
|
|
setCpuCacheSizes(l1,l2);
|
|
|
|
VERIFY(l1==l1CacheSize());
|
|
|
|
VERIFY(l2==l2CacheSize());
|
2010-10-25 22:15:22 +08:00
|
|
|
std::ptrdiff_t k1 = internal::random<int>(10,100)*16;
|
|
|
|
std::ptrdiff_t m1 = internal::random<int>(10,100)*16;
|
|
|
|
std::ptrdiff_t n1 = internal::random<int>(10,100)*16;
|
2010-06-22 14:59:02 +08:00
|
|
|
// only makes sure it compiles fine
|
2010-10-25 22:15:22 +08:00
|
|
|
internal::computeProductBlockingSizes<float,float>(k1,m1,n1);
|
2010-06-11 04:11:31 +08:00
|
|
|
}
|
2010-07-11 04:53:27 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
// test regression in row-vector by matrix (bad Map type)
|
|
|
|
MatrixXf mat1(10,32); mat1.setRandom();
|
|
|
|
MatrixXf mat2(32,32); mat2.setRandom();
|
|
|
|
MatrixXf r1 = mat1.row(2)*mat2.transpose();
|
|
|
|
VERIFY_IS_APPROX(r1, (mat1.row(2)*mat2.transpose()).eval());
|
|
|
|
|
|
|
|
MatrixXf r2 = mat1.row(2)*mat2;
|
|
|
|
VERIFY_IS_APPROX(r2, (mat1.row(2)*mat2).eval());
|
|
|
|
}
|
2009-10-20 02:40:35 +08:00
|
|
|
#endif
|
2008-08-02 07:44:59 +08:00
|
|
|
}
|