From 53c77061f08d220db9955b91b30f65e5d13c6277 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 24 Oct 2016 15:50:27 +0200 Subject: bug #698: rewrite LinSpaced for integer scalar types to avoid overflow and guarantee an even spacing when possible. Otherwise, the "high" bound is implicitly lowered to the largest value allowing for an even distribution. This changeset also disable vectorization for this integer path. --- test/nullary.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'test/nullary.cpp') diff --git a/test/nullary.cpp b/test/nullary.cpp index 35f24de47..162e84210 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -57,23 +57,31 @@ void testVectorType(const VectorType& base) VERIFY_IS_APPROX(m,n); } - VectorType n(size); - for (int i=0; i::IsInteger) || ((high-low)>=size && (Index(high-low)%(size-1))==0) || (Index(high-low+1)::IsInteger) || (high-low>=size)) + for (int i=0; i=0) ? (1+NumTraits::dummy_precision()) : (1-NumTraits::dummy_precision()); + VERIFY( m(m.size()-1) <= high*tol_factor ); VERIFY( size==1 || internal::isApprox(m(0),low) ); // check whether everything works with row and col major vectors @@ -96,7 +104,7 @@ void testVectorType(const VectorType& base) VERIFY_IS_APPROX( ScalarMatrix::LinSpaced(1,low,high), ScalarMatrix::Constant(high) ); // regression test for bug 526 (linear vectorized transversal) - if (size > 1) { + if (size > 1 && (!NumTraits::IsInteger)) { m.tail(size-1).setLinSpaced(low, high); VERIFY_IS_APPROX(m(size-1), high); } -- cgit v1.2.3