Fix many long to int implicit conversions
diff --git a/test/cholesky.cpp b/test/cholesky.cpp
index 1d147bd..a883192 100644
--- a/test/cholesky.cpp
+++ b/test/cholesky.cpp
@@ -181,7 +181,7 @@
     if(rows>=3)
     {
       SquareMatrixType A = symm;
-      int c = internal::random<int>(0,rows-2);
+      Index c = internal::random<Index>(0,rows-2);
       A.bottomRightCorner(c,c).setZero();
       // Make sure a solution exists:
       vecX.setRandom();
@@ -196,7 +196,7 @@
     // check non-full rank matrices
     if(rows>=3)
     {
-      int r = internal::random<int>(1,rows-1);
+      Index r = internal::random<Index>(1,rows-1);
       Matrix<Scalar,Dynamic,Dynamic> a = Matrix<Scalar,Dynamic,Dynamic>::Random(rows,r);
       SquareMatrixType A = a * a.adjoint();
       // Make sure a solution exists:
@@ -215,7 +215,7 @@
       RealScalar s = (std::min)(16,std::numeric_limits<RealScalar>::max_exponent10/8);
       Matrix<Scalar,Dynamic,Dynamic> a = Matrix<Scalar,Dynamic,Dynamic>::Random(rows,rows);
       Matrix<RealScalar,Dynamic,1> d =  Matrix<RealScalar,Dynamic,1>::Random(rows);
-      for(int k=0; k<rows; ++k)
+      for(Index k=0; k<rows; ++k)
         d(k) = d(k)*std::pow(RealScalar(10),internal::random<RealScalar>(-s,s));
       SquareMatrixType A = a * d.asDiagonal() * a.adjoint();
       // Make sure a solution exists:
diff --git a/test/mapstaticmethods.cpp b/test/mapstaticmethods.cpp
index 5b512bd..06272d1 100644
--- a/test/mapstaticmethods.cpp
+++ b/test/mapstaticmethods.cpp
@@ -69,7 +69,8 @@
 {
   static void run(const PlainObjectType& m)
   {
-    int rows = m.rows(), cols = m.cols();
+    typedef typename PlainObjectType::Index Index;
+    Index rows = m.rows(), cols = m.cols();
 
     int i = internal::random<int>(2,5), j = internal::random<int>(2,5);
 
@@ -115,7 +116,8 @@
 {
   static void run(const PlainObjectType& v)
   {
-    int size = v.size();
+    typedef typename PlainObjectType::Index Index;
+    Index size = v.size();
 
     int i = internal::random<int>(2,5);
 
diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp
index 258d238..3a9df61 100644
--- a/test/product_notemporary.cpp
+++ b/test/product_notemporary.cpp
@@ -7,13 +7,12 @@
 // Public License v. 2.0. If a copy of the MPL was not distributed
 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-static int nb_temporaries;
+static long int nb_temporaries;
 
-inline void on_temporary_creation(int size) {
+inline void on_temporary_creation(long int size) {
   // here's a great place to set a breakpoint when debugging failures in this test!
   if(size!=0) nb_temporaries++;
 }
-  
 
 #define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
 
diff --git a/test/ref.cpp b/test/ref.cpp
index 19e8154..d91e3b5 100644
--- a/test/ref.cpp
+++ b/test/ref.cpp
@@ -12,13 +12,12 @@
 #undef EIGEN_DEFAULT_TO_ROW_MAJOR
 #endif
 
-static int nb_temporaries;
+static long int nb_temporaries;
 
-inline void on_temporary_creation(int) {
+inline void on_temporary_creation(long int) {
   // here's a great place to set a breakpoint when debugging failures in this test!
   nb_temporaries++;
 }
-  
 
 #define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
 
diff --git a/test/sparse.h b/test/sparse.h
index e19a763..81ab9e8 100644
--- a/test/sparse.h
+++ b/test/sparse.h
@@ -71,7 +71,7 @@
     //sparseMat.startVec(j);
     for(Index i=0; i<sparseMat.innerSize(); i++)
     {
-      int ai(i), aj(j);
+      Index ai(i), aj(j);
       if(IsRowMajor)
         std::swap(ai,aj);
       Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() : Scalar(0);
@@ -163,7 +163,7 @@
 {
   sparseVec.reserve(int(refVec.size()*density));
   sparseVec.setZero();
-  for(Index i=0; i<refVec.size(); i++)
+  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))
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index 6c620f0..4c9b911 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -147,7 +147,7 @@
       DenseMatrix m1(rows,cols);
       m1.setZero();
       SparseMatrixType m2(rows,cols);
-      VectorXi r(VectorXi::Constant(m2.outerSize(), ((mode%2)==0) ? m2.innerSize() : std::max<int>(1,m2.innerSize()/8)));
+      VectorXi r(VectorXi::Constant(m2.outerSize(), ((mode%2)==0) ? int(m2.innerSize()) : std::max<int>(1,int(m2.innerSize())/8)));
       m2.reserve(r);
       for (int k=0; k<rows*cols; ++k)
       {
@@ -181,7 +181,7 @@
       VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
 
     SparseMatrixType m3(rows,rows);
-    m3.reserve(VectorXi::Constant(rows,rows/2));
+    m3.reserve(VectorXi::Constant(rows,int(rows/2)));
     for(Index j=0; j<rows; ++j)
       for(Index k=0; k<j; ++k)
         m3.insertByOuterInner(j,k) = k+1;
@@ -384,11 +384,11 @@
   {
     typedef Triplet<Scalar,Index> TripletType;
     std::vector<TripletType> triplets;
-    int ntriplets = rows*cols;
+    Index ntriplets = rows*cols;
     triplets.reserve(ntriplets);
     DenseMatrix refMat(rows,cols);
     refMat.setZero();
-    for(int i=0;i<ntriplets;++i)
+    for(Index i=0;i<ntriplets;++i)
     {
       Index r = internal::random<Index>(0,rows-1);
       Index c = internal::random<Index>(0,cols-1);