Fix warning: implicit conversion loses integer precision in SparseMatrix. No need to use std::ptrdiff_t instead of Index since this later is requested to be signed.

This commit is contained in:
Gael Guennebaud 2013-03-20 21:58:24 +01:00
parent 225fd0f579
commit 0a1d9fb9ae

View File

@ -300,11 +300,11 @@ class SparseMatrix
totalReserveSize += reserveSizes[j];
}
m_data.reserve(totalReserveSize);
std::ptrdiff_t previousOuterIndex = m_outerIndex[m_outerSize];
for(std::ptrdiff_t j=m_outerSize-1; j>=0; --j)
Index previousOuterIndex = m_outerIndex[m_outerSize];
for(Index j=m_outerSize-1; j>=0; --j)
{
ptrdiff_t innerNNZ = previousOuterIndex - m_outerIndex[j];
for(std::ptrdiff_t i=innerNNZ-1; i>=0; --i)
Index innerNNZ = previousOuterIndex - m_outerIndex[j];
for(Index i=innerNNZ-1; i>=0; --i)
{
m_data.index(newOuterIndex[j]+i) = m_data.index(m_outerIndex[j]+i);
m_data.value(newOuterIndex[j]+i) = m_data.value(m_outerIndex[j]+i);
@ -327,19 +327,19 @@ class SparseMatrix
{
newOuterIndex[j] = count;
Index alreadyReserved = (m_outerIndex[j+1]-m_outerIndex[j]) - m_innerNonZeros[j];
Index toReserve = std::max<std::ptrdiff_t>(reserveSizes[j], alreadyReserved);
Index toReserve = std::max<Index>(reserveSizes[j], alreadyReserved);
count += toReserve + m_innerNonZeros[j];
}
newOuterIndex[m_outerSize] = count;
m_data.resize(count);
for(ptrdiff_t j=m_outerSize-1; j>=0; --j)
for(Index j=m_outerSize-1; j>=0; --j)
{
std::ptrdiff_t offset = newOuterIndex[j] - m_outerIndex[j];
Index offset = newOuterIndex[j] - m_outerIndex[j];
if(offset>0)
{
std::ptrdiff_t innerNNZ = m_innerNonZeros[j];
for(std::ptrdiff_t i=innerNNZ-1; i>=0; --i)
Index innerNNZ = m_innerNonZeros[j];
for(Index i=innerNNZ-1; i>=0; --i)
{
m_data.index(newOuterIndex[j]+i) = m_data.index(m_outerIndex[j]+i);
m_data.value(newOuterIndex[j]+i) = m_data.value(m_outerIndex[j]+i);
@ -451,7 +451,7 @@ class SparseMatrix
for(Index j=1; j<m_outerSize; ++j)
{
Index nextOldStart = m_outerIndex[j+1];
std::ptrdiff_t offset = oldStart - m_outerIndex[j];
Index offset = oldStart - m_outerIndex[j];
if(offset>0)
{
for(Index k=0; k<m_innerNonZeros[j]; ++k)
@ -1084,12 +1084,12 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse
const Index outer = IsRowMajor ? row : col;
const Index inner = IsRowMajor ? col : row;
std::ptrdiff_t room = m_outerIndex[outer+1] - m_outerIndex[outer];
std::ptrdiff_t innerNNZ = m_innerNonZeros[outer];
Index room = m_outerIndex[outer+1] - m_outerIndex[outer];
Index innerNNZ = m_innerNonZeros[outer];
if(innerNNZ>=room)
{
// this inner vector is full, we need to reallocate the whole buffer :(
reserve(SingletonVector(outer,std::max<std::ptrdiff_t>(2,innerNNZ)));
reserve(SingletonVector(outer,std::max<Index>(2,innerNNZ)));
}
Index startId = m_outerIndex[outer];