reduce float warnings (comparisons and implicit conversions)
diff --git a/test/sparse.h b/test/sparse.h
index 9a63e0d..f3e697d 100644
--- a/test/sparse.h
+++ b/test/sparse.h
@@ -54,7 +54,8 @@
enum { IsRowMajor = SparseMatrix<Scalar,Opt2,StorageIndex>::IsRowMajor };
sparseMat.setZero();
//sparseMat.reserve(int(refMat.rows()*refMat.cols()*density));
- sparseMat.reserve(VectorXi::Constant(IsRowMajor ? refMat.rows() : refMat.cols(), int((1.5*density)*(IsRowMajor?refMat.cols():refMat.rows()))));
+ int nnz = static_cast<int>((1.5 * density) * static_cast<double>(IsRowMajor ? refMat.cols() : refMat.rows()));
+ sparseMat.reserve(VectorXi::Constant(IsRowMajor ? refMat.rows() : refMat.cols(), nnz));
Index insert_count = 0;
for(Index j=0; j<sparseMat.outerSize(); j++)
@@ -82,7 +83,7 @@
if ((flags&ForceRealDiag) && (i==j))
v = numext::real(v);
- if (v!=Scalar(0))
+ if (!numext::is_exactly_zero(v))
{
//sparseMat.insertBackByOuterInner(j,i) = v;
sparseMat.insertByOuterInner(j,i) = v;
@@ -115,7 +116,7 @@
for(int i=0; i<refVec.size(); i++)
{
Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() : Scalar(0);
- if (v!=Scalar(0))
+ if (!numext::is_exactly_zero(v))
{
sparseVec.insertBack(i) = v;
if (nonzeroCoords)