bug #397: add a warning for 64 to 32 bit integer conversion and fix many of these warning by splitting the index type used for storage and as size/coefficient indexes in PermutationMatrix and Transpositions.

This commit is contained in:
Gael Guennebaud
2014-07-17 13:34:26 +02:00
parent 5e72151ca5
commit 77af4cc3c9
11 changed files with 120 additions and 95 deletions

View File

@@ -202,20 +202,20 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
inline Derived& assign(const OtherDerived& other)
{
const bool transpose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? other.rows() : other.cols();
const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? Index(other.rows()) : Index(other.cols());
if ((!transpose) && other.isRValue())
{
// eval without temporary
derived().resize(other.rows(), other.cols());
derived().resize(Index(other.rows()), Index(other.cols()));
derived().setZero();
derived().reserve((std::max)(this->rows(),this->cols())*2);
for (Index j=0; j<outerSize; ++j)
{
derived().startVec(j);
for (typename OtherDerived::InnerIterator it(other, j); it; ++it)
for (typename OtherDerived::InnerIterator it(other, typename OtherDerived::Index(j)); it; ++it)
{
Scalar v = it.value();
derived().insertBackByOuterInner(j,it.index()) = v;
derived().insertBackByOuterInner(j,Index(it.index())) = v;
}
}
derived().finalize();
@@ -237,19 +237,19 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
enum { Flip = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit) };
const Index outerSize = other.outerSize();
const Index outerSize = Index(other.outerSize());
//typedef typename internal::conditional<transpose, LinkedVectorMatrix<Scalar,Flags&RowMajorBit>, Derived>::type TempType;
// thanks to shallow copies, we always eval to a tempary
Derived temp(other.rows(), other.cols());
Derived temp(Index(other.rows()), Index(other.cols()));
temp.reserve((std::max)(this->rows(),this->cols())*2);
for (Index j=0; j<outerSize; ++j)
{
temp.startVec(j);
for (typename OtherDerived::InnerIterator it(other.derived(), j); it; ++it)
for (typename OtherDerived::InnerIterator it(other.derived(), typename OtherDerived::Index(j)); it; ++it)
{
Scalar v = it.value();
temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
temp.insertBackByOuterInner(Flip?Index(it.index()):j,Flip?j:Index(it.index())) = v;
}
}
temp.finalize();
@@ -401,7 +401,7 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
{
dst.setZero();
for (Index j=0; j<outerSize(); ++j)
for (typename Derived::InnerIterator i(derived(),j); i; ++i)
for (typename Derived::InnerIterator i(derived(),typename Derived::Index(j)); i; ++i)
dst.coeffRef(i.row(),i.col()) = i.value();
}