a bunch of problems with 'long int' indexes

Submitted by Albert

Assigned to Nobody

Link to original bugzilla bug (#808)
Version: 3.2
Operating system: Linux

Description

Hi All,

I have RedHat 6.5/64-bit, g++ 4.4.7. Long int indexes cause some problems. All but one of them I had fixed in my local copy of Eigen library. However, the 2nd one is still there.

Serious error - forgotten template parameter in the temporary matrix.
/usr/local/include/eigen3/Eigen/src/SparseCore/SparseMatrix.h:943
--- was:
SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor> trMat(mat.rows(),mat.cols());
--- now:
SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor,Index> trMat(mat.rows(),mat.cols());

Serious error:
/usr/local/include/eigen3/Eigen/src/Core/Functors.h:592:79:
warning: conversion to ‘double’ from ‘long int’ may alter its value
template<typename Index>
EIGEN_STRONG_INLINE const Packet packetOp(Index i) const
{ return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(i),m_interPacket))); }
--- possible reason: pset1() for 'long int' is not defined at:
/usr/local/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h:113
template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float& from) { return _mm_set1_ps(from); }
template<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { return _mm_set1_pd(from); }
template<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int& from) { return _mm_set1_epi32(from); }

warning: conversion to ‘long int’ from ‘double’ may alter its value
/usr/local/include/eigen3/Eigen/src/Core/Functors.h:588
--- was:
template<typename Index>
EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return m_low+i*m_step; }
--- now:
template<typename Index>
EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return m_low+static_cast<Scalar>(i)*m_step; }

warning: conversion to ‘float’ from ‘size_t’ may alter its value
/usr/local/include/eigen3/Eigen/src/SparseCore/CompressedStorage.h:89
--- was:
reallocate(size + size_t(reserveSizeFactor*size));
--- now:
reallocate(size + size_t(static_cast<double>(reserveSizeFactor)*static_cast<double>(size)));

yet another conversion warning:
/usr/local/include/eigen3/Eigen/src/Core/Functors.h:612
--- was:
linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/(num_steps-1))) {}
--- now:
linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/static_cast<Scalar>(num_steps-1))) {}

Blocking

#397 (closed)

Edited by Eigen Bugzilla