From cd25b538abff7370100ef5613b8138919f89c7b0 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 8 Dec 2018 00:13:37 +0100 Subject: Fix noise in sparse_basic_3 (numerical cancellation) --- test/sparse_basic.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/sparse_basic.cpp') diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp index 30d3f1bba..30bba3f07 100644 --- a/test/sparse_basic.cpp +++ b/test/sparse_basic.cpp @@ -658,7 +658,8 @@ void big_sparse_triplet(Index rows, Index cols, double density) { { Index r = internal::random(0,rows-1); Index c = internal::random(0,cols-1); - Scalar v = internal::random(); + // use positive values to prevent numerical cancellation errors in sum + Scalar v = numext::abs(internal::random()); triplets.push_back(TripletType(r,c,v)); sum += v; } -- cgit v1.2.3