1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library 2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra. Eigen itself is part of the KDE project. 3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> 5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// 6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla 7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed 8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#include "product.h" 11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathvoid test_eigen2_product_large() 13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{ 14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath for(int i = 0; i < g_repeat; i++) { 15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST_1( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) ); 16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST_2( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) ); 17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST_3( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) ); 18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST_4( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) ); 19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath CALL_SUBTEST_5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) ); 20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#ifdef EIGEN_TEST_PART_6 23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // test a specific issue in DiagonalProduct 25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath int N = 1000000; 26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VectorXf v = VectorXf::Ones(N); 27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXf m = MatrixXf::Ones(N,3); 28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath m = (v+v).asDiagonal() * m; 29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2)); 30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath // test deferred resizing in Matrix::operator= 34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a; 35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY_IS_APPROX((a = a * b), (c * b).eval()); 36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath 38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath { 39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXf mat1(10,10); mat1.setRandom(); 40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXf mat2(32,10); mat2.setRandom(); 41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath MatrixXf result = mat1.row(2)*mat2.transpose(); 42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath VERIFY_IS_APPROX(result, (mat1.row(2)*mat2.transpose()).eval()); 43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath } 44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#endif 45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} 46