aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sparse_basic.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-12-08 00:13:37 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-12-08 00:13:37 +0100
commitcd25b538abff7370100ef5613b8138919f89c7b0 (patch)
tree77d855f19590ba063af024669e896a8236508ac2 /test/sparse_basic.cpp
parentefaf03bf96bdde4fc48ca7aacb1043bb5ae09b74 (diff)
Fix noise in sparse_basic_3 (numerical cancellation)
Diffstat (limited to 'test/sparse_basic.cpp')
-rw-r--r--test/sparse_basic.cpp3
1 files changed, 2 insertions, 1 deletions
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<Index>(0,rows-1);
Index c = internal::random<Index>(0,cols-1);
- Scalar v = internal::random<Scalar>();
+ // use positive values to prevent numerical cancellation errors in sum
+ Scalar v = numext::abs(internal::random<Scalar>());
triplets.push_back(TripletType(r,c,v));
sum += v;
}