From b027d7a8cfc45fa3f7d6c2162bb76677942dc04a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 24 Oct 2016 20:27:21 +0200 Subject: bug #1004: remove the inaccurate "sequential" path for LinSpaced, mark respective function as deprecated, and enforce strict interpolation of the higher range using a correction term. Now, even with floating point precision, both the 'low' and 'high' bounds are exactly reproduced at i=0 and i=size-1 respectively. --- test/nullary.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'test/nullary.cpp') diff --git a/test/nullary.cpp b/test/nullary.cpp index 162e84210..92514b847 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -73,16 +73,18 @@ void testVectorType(const VectorType& base) VERIFY_IS_APPROX(m,n); VERIFY( internal::isApprox(m(m.size()-1),high) ); VERIFY( size==1 || internal::isApprox(m(0),low) ); - - // sequential access version - m = VectorType::LinSpaced(Sequential,size,low,high); - VERIFY_IS_APPROX(m,n); - VERIFY( internal::isApprox(m(m.size()-1),high) ); + VERIFY_IS_EQUAL(m(m.size()-1) , high); } - Scalar tol_factor = (high>=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) ); + VERIFY( m(m.size()-1) <= high ); + + + VERIFY( m(m.size()-1) >= low ); + if(size>=1) + { + VERIFY( internal::isApprox(m(0),low) ); + VERIFY_IS_EQUAL(m(0) , low); + } // check whether everything works with row and col major vectors Matrix row_vector(size); @@ -187,10 +189,10 @@ void test_nullary() VERIFY(( internal::has_binary_operator >::value )); VERIFY(( !internal::functor_has_linear_access >::ret )); - VERIFY(( !internal::has_nullary_operator >::value )); - VERIFY(( internal::has_unary_operator >::value )); - VERIFY(( !internal::has_binary_operator >::value )); - VERIFY(( internal::functor_has_linear_access >::ret )); + VERIFY(( !internal::has_nullary_operator >::value )); + VERIFY(( internal::has_unary_operator >::value )); + VERIFY(( !internal::has_binary_operator >::value )); + VERIFY(( internal::functor_has_linear_access >::ret )); // Regression unit test for a weird MSVC bug. // Search "nullary_wrapper_workaround_msvc" in CoreEvaluators.h for the details. @@ -211,10 +213,10 @@ void test_nullary() VERIFY(( !internal::has_binary_operator >::value )); VERIFY(( internal::functor_has_linear_access >::ret )); - VERIFY(( !internal::has_nullary_operator >::value )); - VERIFY(( internal::has_unary_operator >::value )); - VERIFY(( !internal::has_binary_operator >::value )); - VERIFY(( internal::functor_has_linear_access >::ret )); + VERIFY(( !internal::has_nullary_operator >::value )); + VERIFY(( internal::has_unary_operator >::value )); + VERIFY(( !internal::has_binary_operator >::value )); + VERIFY(( internal::functor_has_linear_access >::ret )); } #endif } -- cgit v1.2.3