Fix ForceNonZeroDiag for complexes
diff --git a/test/sparse.h b/test/sparse.h
index 3c3a0c9..9912e1e 100644
--- a/test/sparse.h
+++ b/test/sparse.h
@@ -77,8 +77,11 @@
Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() : Scalar(0);
if ((flags&ForceNonZeroDiag) && (i==j))
{
+ // FIXME: the following is too conservative
v = internal::random<Scalar>()*Scalar(3.);
- v = v*v + Scalar(5.);
+ v = v*v;
+ if(numext::real(v)>0) v += Scalar(5);
+ else v -= Scalar(5);
}
if ((flags & MakeLowerTriangular) && aj>ai)
v = Scalar(0);