mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
reduce float warnings (comparisons and implicit conversions)
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
51311ec651
commit
d271a7d545
@@ -54,7 +54,8 @@ initSparse(double density,
|
||||
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 @@ initSparse(double density,
|
||||
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 @@ initSparse(double density,
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user