diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-10-24 15:43:51 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-10-24 15:43:51 +0200 |
commit | e8e56c7642edc0ad15945fa36fc12c1d8a598c27 (patch) | |
tree | 22f94d1a27cdb34f4f22d5f6e36a9be4027da4f6 /test | |
parent | 40f62974b7801c78eb99490b21267cf88d6f644e (diff) |
Add unit test for overflow in LinSpaced
Diffstat (limited to 'test')
-rw-r--r-- | test/nullary.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/nullary.cpp b/test/nullary.cpp index 9063c6de8..35f24de47 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -2,6 +2,7 @@ // for linear algebra. // // Copyright (C) 2010-2011 Jitse Niesen <jitse@maths.leeds.ac.uk> +// Copyright (C) 2016 Gael Guennebaud <gael.guennebaud@inria.fr> // // 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 @@ -135,7 +136,7 @@ void test_nullary() CALL_SUBTEST_2( testMatrixType(MatrixXcf(internal::random<int>(1,300),internal::random<int>(1,300))) ); CALL_SUBTEST_3( testMatrixType(MatrixXf(internal::random<int>(1,300),internal::random<int>(1,300))) ); - for(int i = 0; i < g_repeat; i++) { + for(int i = 0; i < g_repeat*10; i++) { CALL_SUBTEST_4( testVectorType(VectorXd(internal::random<int>(1,300))) ); CALL_SUBTEST_5( testVectorType(Vector4d()) ); // regression test for bug 232 CALL_SUBTEST_6( testVectorType(Vector3d()) ); @@ -154,6 +155,18 @@ void test_nullary() VERIFY( (MatrixXd(RowVectorXd::LinSpaced(3, 0, 1)) - RowVector3d(0, 0.5, 1)).norm() < std::numeric_limits<double>::epsilon() ); #endif +#ifdef EIGEN_TEST_PART_9 + // Check possible overflow issue + { + int n = 60000; + ArrayXi a1(n), a2(n); + a1.setLinSpaced(n, 0, n-1); + for(int i=0; i<n; ++i) + a2(i) = i; + VERIFY_IS_APPROX(a1,a2); + } +#endif + #ifdef EIGEN_TEST_PART_10 // check some internal logic VERIFY(( internal::has_nullary_operator<internal::scalar_constant_op<double> >::value )); |