LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / test / product_large.cpp
blob6bb4d1ad1cd112e1160914ab9a2eef37fd162c32
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@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/.
10 #include "product.h"
12 template<typename T>
13 void test_aliasing()
15 int rows = internal::random<int>(1,12);
16 int cols = internal::random<int>(1,12);
17 typedef Matrix<T,Dynamic,Dynamic> MatrixType;
18 typedef Matrix<T,Dynamic,1> VectorType;
19 VectorType x(cols); x.setRandom();
20 VectorType z(x);
21 VectorType y(rows); y.setZero();
22 MatrixType A(rows,cols); A.setRandom();
23 // CwiseBinaryOp
24 VERIFY_IS_APPROX(x = y + A*x, A*z);
25 x = z;
26 // CwiseUnaryOp
27 VERIFY_IS_APPROX(x = T(1.)*(A*x), A*z);
28 x = z;
29 VERIFY_IS_APPROX(x = y+(-(A*x)), -A*z);
30 x = z;
33 void test_product_large()
35 for(int i = 0; i < g_repeat; i++) {
36 CALL_SUBTEST_1( product(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
37 CALL_SUBTEST_2( product(MatrixXd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
38 CALL_SUBTEST_3( product(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
39 CALL_SUBTEST_4( product(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) );
40 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))) );
42 CALL_SUBTEST_1( test_aliasing<float>() );
45 #if defined EIGEN_TEST_PART_6
47 // test a specific issue in DiagonalProduct
48 int N = 1000000;
49 VectorXf v = VectorXf::Ones(N);
50 MatrixXf m = MatrixXf::Ones(N,3);
51 m = (v+v).asDiagonal() * m;
52 VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2));
56 // test deferred resizing in Matrix::operator=
57 MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a;
58 VERIFY_IS_APPROX((a = a * b), (c * b).eval());
62 // check the functions to setup blocking sizes compile and do not segfault
63 // FIXME check they do what they are supposed to do !!
64 std::ptrdiff_t l1 = internal::random<int>(10000,20000);
65 std::ptrdiff_t l2 = internal::random<int>(1000000,2000000);
66 setCpuCacheSizes(l1,l2);
67 VERIFY(l1==l1CacheSize());
68 VERIFY(l2==l2CacheSize());
69 std::ptrdiff_t k1 = internal::random<int>(10,100)*16;
70 std::ptrdiff_t m1 = internal::random<int>(10,100)*16;
71 std::ptrdiff_t n1 = internal::random<int>(10,100)*16;
72 // only makes sure it compiles fine
73 internal::computeProductBlockingSizes<float,float>(k1,m1,n1);
77 // test regression in row-vector by matrix (bad Map type)
78 MatrixXf mat1(10,32); mat1.setRandom();
79 MatrixXf mat2(32,32); mat2.setRandom();
80 MatrixXf r1 = mat1.row(2)*mat2.transpose();
81 VERIFY_IS_APPROX(r1, (mat1.row(2)*mat2.transpose()).eval());
83 MatrixXf r2 = mat1.row(2)*mat2;
84 VERIFY_IS_APPROX(r2, (mat1.row(2)*mat2).eval());
86 #endif