From 85bee70840a7296f003476769af263f8f6e26042 Mon Sep 17 00:00:00 2001
From: Markus Blatt <mblatt@dune-project.org>
Date: Thu, 30 Jun 2005 12:30:29 +0000
Subject: [PATCH] Introduced a typedef size_type in matrix, vector and
 corresponding arrays and allocator. This should eventually be set to
 std::size_t to address the entries of the allocated entries.

Currently dd crashes if size_type is size_t. Therefore it is still int
right now.

[[Imported from SVN: r282]]
---
 istl/allocator.hh  |  12 ++-
 istl/basearray.hh  | 178 +++++++++++++++++++++++++--------------------
 istl/bcrsmatrix.hh | 155 ++++++++++++++++++++-------------------
 istl/bvector.hh    | 122 +++++++++++++++++--------------
 istl/io.hh         |  26 ++++---
 5 files changed, 272 insertions(+), 221 deletions(-)

diff --git a/istl/allocator.hh b/istl/allocator.hh
index 2ff9f2299..e03379767 100644
--- a/istl/allocator.hh
+++ b/istl/allocator.hh
@@ -1,7 +1,7 @@
 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 // vi: set et ts=4 sw=2 sts=2:
-#ifndef __DUNE_ALLOCATOR_HH__
-#define __DUNE_ALLOCATOR_HH__
+#ifndef DUNE_ALLOCATOR_HH
+#define DUNE_ALLOCATOR_HH
 
 #include <stdlib.h>
 
@@ -24,9 +24,15 @@ namespace Dune {
    */
   class ISTLAllocator { // uses new and delete
   public:
+    //! The size type
+    typedef int size_type;
+
+    //! The difference type to meassure the distance between two pointers
+    typedef std::ptrdiff_t difference_type;
+
     //! allocate array of nmemb objects of type T
     template<class T>
-    static T* malloc (size_t nmemb)
+    static T* malloc (std::size_t nmemb)
     {
       T* p = new T[nmemb];
       return p;
diff --git a/istl/basearray.hh b/istl/basearray.hh
index b75253a9f..dd0e2a524 100644
--- a/istl/basearray.hh
+++ b/istl/basearray.hh
@@ -3,8 +3,9 @@
 #ifndef DUNE_BASEARRAY_HH
 #define DUNE_BASEARRAY_HH
 
-#include <math.h>
+#include <cmath>
 #include <complex>
+#include <cstddef>
 
 #include "istlexception.hh"
 #include "allocator.hh"
@@ -49,23 +50,26 @@ namespace Dune {
     //! export the allocator type
     typedef A allocator_type;
 
+    //! the type for the index access
+    typedef typename A::size_type size_type;
+
 
     //===== access to components
 
     //! random access to blocks
-    B& operator[] (int i)
+    B& operator[] (size_type i)
     {
 #ifdef DUNE_ISTL_WITH_CHECKING
-      if (i<0 || i>=n) DUNE_THROW(ISTLError,"index out of range");
+      if (i>=n) DUNE_THROW(ISTLError,"index out of range");
 #endif
       return p[i];
     }
 
     //! same for read only access
-    const B& operator[] (int i) const
+    const B& operator[] (size_type i) const
     {
 #ifdef DUNE_ISTL_WITH_CHECKING
-      if (i<0 || i>=n) DUNE_THROW(ISTLError,"index out of range");
+      if (i>=n) DUNE_THROW(ISTLError,"index out of range");
 #endif
       return p[i];
     }
@@ -84,7 +88,7 @@ namespace Dune {
         i = 0;
       }
 
-      iterator (B* _p, int _i) : p(_p), i(_i)
+      iterator (const B* _p, B* _i) : p(_p), i(_i)
       {       }
 
       //! prefix increment
@@ -104,83 +108,84 @@ namespace Dune {
       //! equality
       bool operator== (const iterator& it) const
       {
-        return (p+i)==(it.p+it.i);
+        return (i)==(it.i);
       }
 
       //! inequality
       bool operator!= (const iterator& it) const
       {
-        return (p+i)!=(it.p+it.i);
+        return (i)!=(it.i);
       }
 
       //! equality with a const iterator
       bool operator== (const const_iterator& it) const
       {
-        return (p+i)==(it.p+it.i);
+        return (i)==(it.i);
       }
 
       //! inequality with a const iterator
       bool operator!= (const const_iterator& it) const
       {
-        return (p+i)!=(it.p+it.i);
+        return (i)!=(it.i);
       }
 
       //! dereferencing
       B& operator* () const
       {
-        return p[i];
+        return *i;
       }
 
       //! arrow
       B* operator-> () const
       {
-        return p+i;
+        return i;
       }
 
       //! return index corresponding to pointer
-      int index () const
+      size_type index () const
       {
-        return i;
+        return i-p;
       }
 
       friend class const_iterator;
 
     private:
-      B* p;
-      int i;
+      const B* p;
+      B* i;
+
     };
 
     //! begin iterator
     iterator begin ()
     {
-      return iterator(p,0);
+      return iterator(p,p);
     }
 
     //! end iterator
     iterator end ()
     {
-      return iterator(p,n);
+      return iterator(p,p+n);
     }
 
     //! begin reverse iterator
     iterator rbegin ()
     {
-      return iterator(p,n-1);
+      return iterator(p,p+n-1);
     }
 
     //! end reverse iterator
     iterator rend ()
     {
-      return iterator(p,-1);
+      return iterator(p,p-1);
     }
 
     //! random access returning iterator (end if not contained)
-    iterator find (int i)
+    iterator find (size_type i)
     {
-      if (i>=0 && i<n)
-        return iterator(p,i);
+      if (i<n)
+        return iterator(p,p+i);
       else
-        return iterator(p,n);
+        return iterator(p,p+n);
     }
 
     //! const_iterator class for sequential access
@@ -194,7 +199,7 @@ namespace Dune {
         i = 0;
       }
 
-      const_iterator (const B* _p, int _i) : p(_p), i(_i)
+      const_iterator (const B* _p, const B* _i) : p(_p), i(_i)
       {       }
 
       const_iterator (const iterator& it) : p(it.p), i(it.i)
@@ -217,90 +222,90 @@ namespace Dune {
       //! equality
       bool operator== (const const_iterator& it) const
       {
-        return (p+i)==(it.p+it.i);
+        return (i)==(it.i);
       }
 
       //! inequality
       bool operator!= (const const_iterator& it) const
       {
-        return (p+i)!=(it.p+it.i);
+        return (i)!=(it.i);
       }
 
       //! equality
       bool operator== (const iterator& it) const
       {
-        return (p+i)==(it.p+it.i);
+        return (i)==(it.i);
       }
 
       //! inequality
       bool operator!= (const iterator& it) const
       {
-        return (p+i)!=(it.p+it.i);
+        return (i)!=(it.i);
       }
 
       //! dereferencing
       const B& operator* () const
       {
-        return p[i];
+        return *i;
       }
 
       //! arrow
       const B* operator-> () const
       {
-        return p+i;
+        return i;
       }
 
       //! return index corresponding to pointer
-      int index () const
+      size_type index () const
       {
-        return i;
+        return i-p;
       }
 
       friend class iterator;
 
     private:
       const B* p;
-      int i;
+      const B* i;
     };
 
     //! begin const_iterator
     const_iterator begin () const
     {
-      return const_iterator(p,0);
+      return const_iterator(p,p+0);
     }
 
     //! end const_iterator
     const_iterator end () const
     {
-      return const_iterator(p,n);
+      return const_iterator(p,p+n);
     }
 
     //! begin reverse const_iterator
     const_iterator rbegin () const
     {
-      return const_iterator(p,n-1);
+      return const_iterator(p,p+n-1);
     }
 
     //! end reverse const_iterator
     const_iterator rend () const
     {
-      return const_iterator(p,-1);
+      return const_iterator(p,p-1);
     }
 
     //! random access returning iterator (end if not contained)
-    const_iterator find (int i) const
+    const_iterator find (size_type i) const
     {
-      if (i>=0 && i<n)
-        return const_iterator(p,i);
+      if (i<n)
+        return const_iterator(p,p+i);
       else
-        return const_iterator(p,n);
+        return const_iterator(p,p+n);
     }
 
 
     //===== sizes
 
     //! number of blocks in the array (are of size 1 here)
-    int size () const
+    size_type size () const
     {
       return n;
     }
@@ -313,7 +318,7 @@ namespace Dune {
       p = 0;
     }
 
-    int n;     // number of elements in array
+    size_type n;     // number of elements in array
     B *p;      // pointer to dynamically allocated built-in array
   };
 
@@ -352,6 +357,11 @@ namespace Dune {
     //! make iterators available as types
     typedef typename base_array_unmanaged<B,A>::const_iterator const_iterator;
 
+    //! The type used for the index access
+    typedef typename base_array_unmanaged<B,A>::size_type size_type;
+
+    //! The type used for the difference between two iterator positions
+    typedef typename A::difference_type difference_type;
 
     //===== constructors and such
 
@@ -363,7 +373,7 @@ namespace Dune {
     }
 
     //! make array from given pointer and size
-    base_array_window (B* _p, int _n)
+    base_array_window (B* _p, size_type _n)
     {
       this->n = _n;
       this->p = _p;
@@ -372,28 +382,28 @@ namespace Dune {
     //===== window manipulation methods
 
     //! set pointer and length
-    void set (int _n, B* _p)
+    void set (size_type _n, B* _p)
     {
       this->n = _n;
       this->p = _p;
     }
 
     //! advance pointer by newsize elements and then set size to new size
-    void advance (int newsize)
+    void advance (difference_type newsize)
     {
       this->p += this->n;
       this->n = newsize;
     }
 
     //! increment pointer by offset and set size
-    void move (int offset, int newsize)
+    void move (difference_type offset, size_type newsize)
     {
       this->p += offset;
       this->n = newsize;
     }
 
     //! increment pointer by offset, leave size
-    void move (int offset)
+    void move (difference_type offset)
     {
       this->p += offset;
     }
@@ -441,6 +451,12 @@ namespace Dune {
     //! make iterators available as types
     typedef typename base_array_unmanaged<B,A>::const_iterator const_iterator;
 
+    //! The type used for the index access
+    typedef typename base_array_unmanaged<B,A>::size_type size_type;
+
+    //! The type used for the difference between two iterator positions
+    typedef typename A::difference_type difference_type;
+
     //===== constructors and such
 
     //! makes empty array
@@ -451,7 +467,7 @@ namespace Dune {
     }
 
     //! make array with _n components
-    base_array (int _n)
+    base_array (size_type _n)
     {
       this->n = _n;
       if (this->n>0)
@@ -477,7 +493,7 @@ namespace Dune {
       }
 
       // and copy elements
-      for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+      for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
     }
 
     //! construct from base class object
@@ -496,7 +512,7 @@ namespace Dune {
       }
 
       // and copy elements
-      for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+      for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
     }
 
 
@@ -507,7 +523,7 @@ namespace Dune {
     }
 
     //! reallocate array to given size, any data is lost
-    void resize (int _n)
+    void resize (size_type _n)
     {
       if (this->n==_n) return;
 
@@ -541,7 +557,7 @@ namespace Dune {
           }
         }
         // copy data
-        for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+        for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
       }
       return *this;
     }
@@ -588,16 +604,18 @@ namespace Dune {
     //! export the allocator type
     typedef A allocator_type;
 
+    //! The type used for the index access
+    typedef typename A::size_type size_type;
 
     //===== access to components
 
     //! random access to blocks, assumes ascending ordering
-    B& operator[] (int i)
+    B& operator[] (size_type i)
     {
-      int l=0, r=n-1;
+      size_type l=0, r=n-1;
       while (l<r)
       {
-        int q = (l+r)/2;
+        size_type q = (l+r)/2;
         if (i <= j[q]) r=q;
         else l = q+1;
       }
@@ -608,12 +626,12 @@ namespace Dune {
     }
 
     //! same for read only access, assumes ascending ordering
-    const B& operator[] (int i) const
+    const B& operator[] (size_type i) const
     {
-      int l=0, r=n-1;
+      size_type l=0, r=n-1;
       while (l<r)
       {
-        int q = (l+r)/2;
+        size_type q = (l+r)/2;
         if (i <= j[q]) r=q;
         else l = q+1;
       }
@@ -638,7 +656,7 @@ namespace Dune {
         i = 0;
       }
 
-      iterator (B* _p, int* _j, int _i) : p(_p), j(_j), i(_i)
+      iterator (B* _p, size_type* _j, size_type _i) : p(_p), j(_j), i(_i)
       {       }
 
       //! prefix increment
@@ -696,13 +714,13 @@ namespace Dune {
       }
 
       //! return index corresponding to pointer
-      int index () const
+      size_type index () const
       {
         return j[i];
       }
 
       //! Set index corresponding to pointer
-      void setindex (int k)
+      void setindex (size_type k)
       {
         return j[i] = k;
       }
@@ -714,7 +732,7 @@ namespace Dune {
        * has to be increment this amount of times to
        * the same position.
        */
-      int offset () const
+      size_type offset () const
       {
         return i;
       }
@@ -723,8 +741,8 @@ namespace Dune {
 
     private:
       B* p;
-      int* j;
-      int i;
+      size_type* j;
+      size_type i;
     };
 
     //! begin iterator
@@ -752,12 +770,12 @@ namespace Dune {
     }
 
     //! random access returning iterator (end if not contained)
-    iterator find (int i)
+    iterator find (size_type i)
     {
-      int l=0, r=n-1;
+      size_type l=0, r=n-1;
       while (l<r)
       {
-        int q = (l+r)/2;
+        size_type q = (l+r)/2;
         if (i <= j[q]) r=q;
         else l = q+1;
       }
@@ -781,7 +799,7 @@ namespace Dune {
       }
 
       //! \todo please doc me!
-      const_iterator (const B* _p, const int* _j, int _i) : p(_p), j(_j), i(_i)
+      const_iterator (const B* _p, const size_type* _j, size_type _i) : p(_p), j(_j), i(_i)
       {       }
 
       //! Copy constructor from a non-const iterator
@@ -843,7 +861,7 @@ namespace Dune {
       }
 
       //! return index corresponding to pointer
-      int index () const
+      size_type index () const
       {
         return j[i];
       }
@@ -855,7 +873,7 @@ namespace Dune {
        * has to be increment this amount of times to
        * the same position.
        */
-      int offset () const
+      size_type offset () const
       {
         return i;
       }
@@ -864,8 +882,8 @@ namespace Dune {
 
     private:
       const B* p;
-      const int* j;
-      int i;
+      const size_type* j;
+      size_type i;
     };
 
     //! begin const_iterator
@@ -893,12 +911,12 @@ namespace Dune {
     }
 
     //! random access returning iterator (end if not contained)
-    const_iterator find (int i) const
+    const_iterator find (size_type i) const
     {
-      int l=0, r=n-1;
+      size_type l=0, r=n-1;
       while (l<r)
       {
-        int q = (l+r)/2;
+        size_type q = (l+r)/2;
         if (i <= j[q]) r=q;
         else l = q+1;
       }
@@ -912,7 +930,7 @@ namespace Dune {
     //===== sizes
 
     //! number of blocks in the array (are of size 1 here)
-    int size () const
+    size_type size () const
     {
       return n;
     }
@@ -926,9 +944,9 @@ namespace Dune {
       j = 0;
     }
 
-    int n;      // number of elements in array
+    size_type n;      // number of elements in array
     B *p;       // pointer to dynamically allocated built-in array
-    int* j;     // the index set
+    size_type* j;     // the index set
   };
 
 
diff --git a/istl/bcrsmatrix.hh b/istl/bcrsmatrix.hh
index 5f4300eed..c88efcf54 100644
--- a/istl/bcrsmatrix.hh
+++ b/istl/bcrsmatrix.hh
@@ -71,6 +71,9 @@ namespace Dune {
     //! implement row_type with compressed vector
     typedef CompressedBlockVectorWindow<B,A> row_type;
 
+    //! The type for the index access and the size
+    typedef typename A::size_type size_type;
+
     //! increment block level counter
     enum {
       //! The number of blocklevels the matrix contains.
@@ -109,22 +112,22 @@ namespace Dune {
     //===== random access interface to rows of the matrix
 
     //! random access to the rows
-    row_type& operator[] (int i)
+    row_type& operator[] (size_type i)
     {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (r==0) DUNE_THROW(ISTLError,"row not initialized yet");
-      if (i<0 || i>=n) DUNE_THROW(ISTLError,"index out of range");
+      if (i>=n) DUNE_THROW(ISTLError,"index out of range");
       if (r[i].getptr()==0) DUNE_THROW(ISTLError,"row not initialized yet");
 #endif
       return r[i];
     }
 
     //! same for read only access
-    const row_type& operator[] (int i) const
+    const row_type& operator[] (size_type i) const
     {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (!ready) DUNE_THROW(ISTLError,"row not initialized yet");
-      if (i<0 || i>=n) DUNE_THROW(ISTLError,"index out of range");
+      if (i>=n) DUNE_THROW(ISTLError,"index out of range");
 #endif
       return r[i];
     }
@@ -140,7 +143,7 @@ namespace Dune {
     {
     public:
       //! constructor
-      Iterator (row_type* _p, int _i)
+      Iterator (row_type* _p, size_type _i)
       {
         p = _p;
         i = _i;
@@ -197,7 +200,7 @@ namespace Dune {
       }
 
       //! return index
-      int index ()
+      size_type index ()
       {
         return i;
       }
@@ -206,7 +209,7 @@ namespace Dune {
 
     private:
       row_type* p;
-      int i;
+      size_type i;
     };
 
     //! Get iterator to first row
@@ -245,7 +248,7 @@ namespace Dune {
     {
     public:
       //! constructor
-      ConstIterator (const row_type* _p, int _i) : p(_p), i(_i)
+      ConstIterator (const row_type* _p, size_type _i) : p(_p), i(_i)
       {       }
 
       //! empty constructor, use with care!
@@ -311,7 +314,7 @@ namespace Dune {
       }
 
       //! return index
-      int index () const
+      size_type index () const
       {
         return i;
       }
@@ -320,7 +323,7 @@ namespace Dune {
 
     private:
       const row_type* p;
-      int i;
+      size_type i;
     };
 
     //! Get const iterator to first row
@@ -376,7 +379,7 @@ namespace Dune {
     }
 
     //! matrix with known number of nonzeroes
-    BCRSMatrix (int _n, int _m, int _nnz, BuildMode bm)
+    BCRSMatrix (size_type _n, size_type _m, size_type _nnz, BuildMode bm)
     {
       // the state
       build_mode = bm;
@@ -401,7 +404,7 @@ namespace Dune {
       if (nnz>0)
       {
         a = A::template malloc<B>(nnz);
-        j = A::template malloc<int>(nnz);
+        j = A::template malloc<size_type>(nnz);
       }
       else
       {
@@ -411,7 +414,7 @@ namespace Dune {
     }
 
     //! matrix with unknown number of nonzeroes
-    BCRSMatrix (int _n, int _m, BuildMode bm)
+    BCRSMatrix (size_type _n, size_type _m, BuildMode bm)
     {
       // the state
       build_mode = bm;
@@ -451,7 +454,7 @@ namespace Dune {
       if (nnz<=0)
       {
         nnz = 0;
-        for (int i=0; i<n; i++)
+        for (size_type i=0; i<n; i++)
           nnz += Mat.r[i].getsize();
       }
 
@@ -469,7 +472,7 @@ namespace Dune {
       if (nnz>0)
       {
         a = A::template malloc<B>(nnz);
-        j = A::template malloc<int>(nnz);
+        j = A::template malloc<size_type>(nnz);
       }
       else
       {
@@ -478,7 +481,7 @@ namespace Dune {
       }
 
       // build window structure
-      for (int i=0; i<n; i++)
+      for (size_type i=0; i<n; i++)
       {
         // set row i
         r[i].setsize(Mat.r[i].getsize());
@@ -495,7 +498,7 @@ namespace Dune {
       }
 
       // copy data
-      for (int i=0; i<n; i++) r[i] = Mat.r[i];
+      for (size_type i=0; i<n; i++) r[i] = Mat.r[i];
 
       // finish off
       build_mode = row_wise;     // dummy
@@ -508,16 +511,16 @@ namespace Dune {
       if (nnz>0)
       {
         // a,j have been allocated as one long vector
-        A::template free<int>(j);
+        A::template free<size_type>(j);
         A::template free<B>(a);
       }
       else
       {
         // check if memory for rows have been allocated individually
-        for (int i=0; i<n; i++)
+        for (size_type i=0; i<n; i++)
           if (r[i].getsize()>0)
           {
-            A::template free<int>(r[i].getindexptr());
+            A::template free<size_type>(r[i].getindexptr());
             A::template free<B>(r[i].getptr());
           }
       }
@@ -536,16 +539,16 @@ namespace Dune {
       if (nnz>0)
       {
         // a,j have been allocated as one long vector
-        A::template free<int>(j);
+        A::template free<size_type>(j);
         A::template free<B>(a);
       }
       else
       {
         // check if memory for rows have been allocated individually
-        for (int i=0; i<n; i++)
+        for (size_type i=0; i<n; i++)
           if (r[i].getsize()>0)
           {
-            A::template free<int>(r[i].getindexptr());
+            A::template free<size_type>(r[i].getindexptr());
             A::template free<B>(r[i].getptr());
           }
       }
@@ -576,7 +579,7 @@ namespace Dune {
       if (nnz<=0)
       {
         nnz = 0;
-        for (int i=0; i<n; i++)
+        for (size_type i=0; i<n; i++)
           nnz += Mat.r[i].getsize();
       }
 
@@ -584,7 +587,7 @@ namespace Dune {
       if (nnz>0)
       {
         a = A::template malloc<B>(nnz);
-        j = A::template malloc<int>(nnz);
+        j = A::template malloc<size_type>(nnz);
       }
       else
       {
@@ -593,7 +596,7 @@ namespace Dune {
       }
 
       // build window structure
-      for (int i=0; i<n; i++)
+      for (size_type i=0; i<n; i++)
       {
         // set row i
         r[i].setsize(Mat.r[i].getsize());
@@ -610,7 +613,7 @@ namespace Dune {
       }
 
       // copy data
-      for (int i=0; i<n; i++) r[i] = Mat.r[i];
+      for (size_type i=0; i<n; i++) r[i] = Mat.r[i];
 
       // finish off
       build_mode = row_wise;     // dummy
@@ -621,7 +624,7 @@ namespace Dune {
     //! Assignment from a scalar
     BCRSMatrix& operator= (const field_type& k)
     {
-      for (int i=0; i<n; i++) r[i] = k;
+      for (size_type i=0; i<n; i++) r[i] = k;
       return *this;
     }
 
@@ -632,7 +635,7 @@ namespace Dune {
     {
     public:
       //! constructor
-      CreateIterator (BCRSMatrix& _Mat, int _i) : Mat(_Mat)
+      CreateIterator (BCRSMatrix& _Mat, size_type _i) : Mat(_Mat)
       {
         if (Mat.build_mode!=row_wise)
           DUNE_THROW(ISTLError,"creation only allowed for uninitialized matrix");
@@ -653,7 +656,7 @@ namespace Dune {
         // this depends on the allocation mode
 
         // compute size of the row
-        int s = pattern.size();
+        size_type s = pattern.size();
 
         // update number of nonzeroes including this row
         nnz += s;
@@ -681,7 +684,7 @@ namespace Dune {
           if (s>0)
           {
             B*   a = A::template malloc<B>(s);
-            int* j = A::template malloc<int>(s);
+            size_type* j = A::template malloc<size_type>(s);
             Mat.r[i].set(s,a,j);
           }
           else
@@ -689,9 +692,9 @@ namespace Dune {
         }
 
         // initialize the j array for row i from pattern
-        int k=0;
-        int *j =  Mat.r[i].getindexptr();
-        for (std::set<int>::const_iterator it=pattern.begin(); it!=pattern.end(); ++it)
+        size_type k=0;
+        size_type *j =  Mat.r[i].getindexptr();
+        for (typename std::set<size_type>::const_iterator it=pattern.begin(); it!=pattern.end(); ++it)
           j[k++] = *it;
 
         // now go to next row
@@ -720,19 +723,19 @@ namespace Dune {
       }
 
       //! dereferencing
-      int index ()
+      size_type index ()
       {
         return i;
       }
 
       //! put column index in row
-      void insert (int j)
+      void insert (size_type j)
       {
         pattern.insert(j);
       }
 
       //! return true if column index is in row
-      bool contains (int j)
+      bool contains (size_type j)
       {
         if (pattern.find(j)!=pattern.end())
           return true;
@@ -742,9 +745,9 @@ namespace Dune {
 
     private:
       BCRSMatrix& Mat;     // the matrix we are defining
-      int i;               // current row to be defined
-      int nnz;             // count total number of nonzeros
-      std::set<int> pattern;     // used to compile entries in a row
+      size_type i;               // current row to be defined
+      size_type nnz;             // count total number of nonzeros
+      std::set<size_type> pattern;     // used to compile entries in a row
     };
 
 
@@ -767,7 +770,7 @@ namespace Dune {
     //===== random creation interface
 
     //! set number of indices in row i to s
-    void setrowsize (int i, int s)
+    void setrowsize (size_type i, size_type s)
     {
       if (build_mode!=random)
         DUNE_THROW(ISTLError,"requires random build mode");
@@ -778,7 +781,7 @@ namespace Dune {
     }
 
     //! increment size of row i by 1
-    void incrementrowsize (int i)
+    void incrementrowsize (size_type i)
     {
       if (build_mode!=random)
         DUNE_THROW(ISTLError,"requires random build mode");
@@ -797,8 +800,8 @@ namespace Dune {
         DUNE_THROW(ISTLError,"matrix already built up");
 
       // compute total size, check positivity
-      int total=0;
-      for (int i=0; i<n; i++)
+      size_type total=0;
+      for (size_type i=0; i<n; i++)
       {
         if (r[i].getsize()<=0)
           DUNE_THROW(ISTLError,"rowsize must be positive");
@@ -819,7 +822,7 @@ namespace Dune {
         if (nnz>0)
         {
           a = A::template malloc<B>(nnz);
-          j = A::template malloc<int>(nnz);
+          j = A::template malloc<size_type>(nnz);
         }
         else
         {
@@ -829,7 +832,7 @@ namespace Dune {
       }
 
       // set the window pointers correctly
-      for (int i=0; i<n; i++)
+      for (size_type i=0; i<n; i++)
       {
         // set row i
         if (i==0)
@@ -846,12 +849,12 @@ namespace Dune {
 
       // initialize j array with m (an invalid column index)
       // this indicates an unused entry
-      for (int k=0; k<nnz; k++)
+      for (size_type k=0; k<nnz; k++)
         j[k] = m;
     }
 
     //! add index (row,col) to the matrix
-    void addindex (int row, int col)
+    void addindex (size_type row, size_type col)
     {
       if (build_mode!=random)
         DUNE_THROW(ISTLError,"requires random build mode");
@@ -859,14 +862,14 @@ namespace Dune {
         DUNE_THROW(ISTLError,"matrix already built up");
 
       // get row
-      int* p = r[row].getindexptr();
-      int s = r[row].getsize();
+      size_type* p = r[row].getindexptr();
+      size_type s = r[row].getsize();
 
       // binary search for col
-      int l=0, r=s-1;
+      size_type l=0, r=s-1;
       while (l<r)
       {
-        int q = (l+r)/2;
+        size_type q = (l+r)/2;
         if (col <= p[q]) r=q;
         else l = q+1;
       }
@@ -878,7 +881,7 @@ namespace Dune {
       l=0; r=s-1;
       while (l<r)
       {
-        int q = (l+r)/2;
+        size_type q = (l+r)/2;
         if (m <= p[q]) r=q;
         else l = q+1;
       }
@@ -889,7 +892,7 @@ namespace Dune {
       p[l] = col;
 
       // use insertion sort to move index to correct position
-      for (int i=l-1; i>=0; i--)
+      for (size_type i=l-1; i>=0; i--)
         if (p[i]>p[i+1])
           std::swap(p[i],p[i+1]);
         else
@@ -905,7 +908,7 @@ namespace Dune {
         DUNE_THROW(ISTLError,"matrix already built up");
 
       // check if there are undefined indices
-      for (int k=0; k<nnz; k++)
+      for (size_type k=0; k<nnz; k++)
         if (j[k]<0 || j[k]>=m)
         {
           std::cout << "j[" << k << "]=" << j[k] << std::endl;
@@ -923,7 +926,7 @@ namespace Dune {
       if (nnz>0)
       {
         // process 1D array
-        for (int i=0; i<nnz; i++)
+        for (size_type i=0; i<nnz; i++)
           a[i] *= k;
       }
       else
@@ -946,7 +949,7 @@ namespace Dune {
       if (nnz>0)
       {
         // process 1D array
-        for (int i=0; i<nnz; i++)
+        for (size_type i=0; i<nnz; i++)
           a[i] /= k;
       }
       else
@@ -1180,41 +1183,41 @@ namespace Dune {
     //===== sizes
 
     //! number of blocks in row direction
-    int N () const
+    size_type N () const
     {
       return n;
     }
 
     //! number of blocks in column direction
-    int M () const
+    size_type M () const
     {
       return m;
     }
 
     //! row dimension of block r
-    int rowdim (int i) const
+    size_type rowdim (size_type i) const
     {
       return r[i].getptr()->rowdim();
     }
 
     //! col dimension of block c
-    int coldim (int c) const
+    size_type coldim (size_type c) const
     {
       // find an entry in column j
       if (nnz>0)
       {
-        for (int k=0; k<nnz; k++)
+        for (size_type k=0; k<nnz; k++)
           if (j[k]==c) {
             return a[k].coldim();
           }
       }
       else
       {
-        for (int i=0; i<n; i++)
+        for (size_type i=0; i<n; i++)
         {
-          int* j = r[i].getindexptr();
+          size_type* j = r[i].getindexptr();
           B*   a = r[i].getptr();
-          for (int k=0; k<r[i].getsize(); k++)
+          for (size_type k=0; k<r[i].getsize(); k++)
             if (j[k]==c) {
               return a[k].coldim();
             }
@@ -1226,19 +1229,19 @@ namespace Dune {
     }
 
     //! dimension of the destination vector space
-    int rowdim () const
+    size_type rowdim () const
     {
-      int nn=0;
-      for (int i=0; i<n; i++)
+      size_type nn=0;
+      for (size_type i=0; i<n; i++)
         nn += rowdim(i);
       return nn;
     }
 
     //! dimension of the source vector space
-    int coldim () const
+    size_type coldim () const
     {
-      int mm=0;
-      for (int i=0; i<m; i++)
+      size_type mm=0;
+      for (size_type i=0; i<m; i++)
         mm += coldim(i);
       return mm;
     }
@@ -1246,7 +1249,7 @@ namespace Dune {
     //===== query
 
     //! return true if (i,j) is in pattern
-    bool exists (int i, int j) const
+    bool exists (size_type i, size_type j) const
     {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (i<0 || i>=n) DUNE_THROW(ISTLError,"index out of range");
@@ -1265,9 +1268,9 @@ namespace Dune {
     bool ready;               // true if matrix is ready to use
 
     // size of the matrix
-    int n;       // number of rows
-    int m;       // number of columns
-    int nnz;     // number of nonzeros allocated in the a and j array below
+    size_type n;       // number of rows
+    size_type m;       // number of columns
+    size_type nnz;     // number of nonzeros allocated in the a and j array below
     // zero means that memory is allocated seperately for each row.
 
     // the rows are dynamically allocated
@@ -1275,7 +1278,7 @@ namespace Dune {
 
     // dynamically allocated memory
     B*   a;      // [nnz] non-zero entries of the matrix in row-wise ordering
-    int* j;      // [nnz] column indices of entries
+    size_type* j;      // [nnz] column indices of entries
   };
 
 
diff --git a/istl/bvector.hh b/istl/bvector.hh
index 6fdd62652..463a2bfed 100644
--- a/istl/bvector.hh
+++ b/istl/bvector.hh
@@ -52,6 +52,9 @@ namespace Dune {
     //! export the allocator type
     typedef A allocator_type;
 
+    //! The size type for the index access
+    typedef typename A::size_type size_type;
+
     //! make iterators available as types
     typedef typename base_array_unmanaged<B,A>::iterator Iterator;
 
@@ -64,7 +67,7 @@ namespace Dune {
     //! Assignment from a scalar
     block_vector_unmanaged& operator= (const field_type& k)
     {
-      for (int i=0; i<this->n; i++)
+      for (size_type i=0; i<this->n; i++)
         (*this)[i] = k;
       return *this;
     }
@@ -78,7 +81,7 @@ namespace Dune {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
 #endif
-      for (int i=0; i<this->n; ++i) (*this)[i] += y[i];
+      for (size_type i=0; i<this->n; ++i) (*this)[i] += y[i];
       return *this;
     }
 
@@ -88,14 +91,14 @@ namespace Dune {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
 #endif
-      for (int i=0; i<this->n; ++i) (*this)[i] -= y[i];
+      for (size_type i=0; i<this->n; ++i) (*this)[i] -= y[i];
       return *this;
     }
 
     //! vector space multiplication with scalar
     block_vector_unmanaged& operator*= (const field_type& k)
     {
-      for (int i=0; i<this->n; ++i) (*this)[i] *= k;
+      for (size_type i=0; i<this->n; ++i) (*this)[i] *= k;
       return *this;
     }
 
@@ -112,7 +115,7 @@ namespace Dune {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
 #endif
-      for (int i=0; i<this->n; ++i) (*this)[i].axpy(a,y[i]);
+      for (size_type i=0; i<this->n; ++i) (*this)[i].axpy(a,y[i]);
       return *this;
     }
 
@@ -126,7 +129,7 @@ namespace Dune {
       if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
 #endif
       field_type sum=0;
-      for (int i=0; i<this->n; ++i) sum += (*this)[i]*y[i];
+      for (size_type i=0; i<this->n; ++i) sum += (*this)[i]*y[i];
       return sum;
     }
 
@@ -137,7 +140,7 @@ namespace Dune {
     double one_norm () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (*this)[i].one_norm();
+      for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm();
       return sum;
     }
 
@@ -145,7 +148,7 @@ namespace Dune {
     double one_norm_real () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (*this)[i].one_norm_real();
+      for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm_real();
       return sum;
     }
 
@@ -153,7 +156,7 @@ namespace Dune {
     double two_norm () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
+      for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
       return sqrt(sum);
     }
 
@@ -161,7 +164,7 @@ namespace Dune {
     double two_norm2 () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
+      for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
       return sum;
     }
 
@@ -169,7 +172,7 @@ namespace Dune {
     double infinity_norm () const
     {
       double max=0;
-      for (int i=0; i<this->n; ++i) max = std::max(max,(*this)[i].infinity_norm());
+      for (size_type i=0; i<this->n; ++i) max = std::max(max,(*this)[i].infinity_norm());
       return max;
     }
 
@@ -177,7 +180,7 @@ namespace Dune {
     double infinity_norm_real () const
     {
       double max=0;
-      for (int i=0; i<this->n; ++i) max = std::max(max,(*this)[i].infinity_norm_real());
+      for (size_type i=0; i<this->n; ++i) max = std::max(max,(*this)[i].infinity_norm_real());
       return max;
     }
 
@@ -185,16 +188,16 @@ namespace Dune {
     //===== sizes
 
     //! number of blocks in the vector (are of size 1 here)
-    int N () const
+    size_type N () const
     {
       return this->n;
     }
 
     //! dimension of the vector space
-    int dim () const
+    size_type dim () const
     {
-      int d=0;
-      for (int i=0; i<this->n; i++)
+      size_type d=0;
+      for (size_type i=0; i<this->n; i++)
         d += (*this)[i].dim();
       return d;
     }
@@ -232,6 +235,9 @@ namespace Dune {
     //! export the allocator type
     typedef A allocator_type;
 
+    //! The type for the index access
+    typedef typename A::size_type size_type;
+
     //! increment block level counter
     enum {
       //! The number of blocklevel we contain.
@@ -251,7 +257,7 @@ namespace Dune {
     {       }
 
     //! make vector with _n components
-    BlockVector (int _n)
+    BlockVector (size_type _n)
     {
       this->n = _n;
       if (this->n>0)
@@ -278,7 +284,7 @@ namespace Dune {
       }
 
       // and copy elements
-      for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+      for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
     }
 
     //! construct from base class object
@@ -298,7 +304,7 @@ namespace Dune {
       }
 
       // and copy elements
-      for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+      for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
     }
 
 
@@ -309,7 +315,7 @@ namespace Dune {
     }
 
     //! reallocate vector to given size, any data is lost
-    void resize (int _n)
+    void resize (size_type _n)
     {
       if (this->n==_n) return;
 
@@ -343,7 +349,7 @@ namespace Dune {
           }
         }
         // copy data
-        for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+        for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
       }
       return *this;
     }
@@ -368,7 +374,9 @@ namespace Dune {
   template<class K, class A>
   std::ostream& operator<< (std::ostream& s, const BlockVector<K, A>& v)
   {
-    for (int i=0; i<v.size(); i++)
+    typedef typename  BlockVector<K, A>::size_type size_type;
+
+    for (size_type i=0; i<v.size(); i++)
       s << v[i] << std::endl;
 
     return s;
@@ -406,6 +414,9 @@ namespace Dune {
     //! export the allocator type
     typedef A allocator_type;
 
+    //! The type for the index access
+    typedef typename A::size_type size_type;
+
     //! increment block level counter
     enum {
       //! The number of blocklevels we contain
@@ -425,7 +436,7 @@ namespace Dune {
     {       }
 
     //! make array from given pointer and size
-    BlockVectorWindow (B* _p, int _n)
+    BlockVectorWindow (B* _p, size_type _n)
     {
       this->n = _n;
       this->p = _p;
@@ -461,7 +472,7 @@ namespace Dune {
       if (&a!=this)     // check if this and a are different objects
       {
         // copy data
-        for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
+        for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
       }
       return *this;
     }
@@ -484,14 +495,14 @@ namespace Dune {
     //===== window manipulation methods
 
     //! set size and pointer
-    void set (int _n, B* _p)
+    void set (size_type _n, B* _p)
     {
       this->n = _n;
       this->p = _p;
     }
 
     //! set size only
-    void setsize (int _n)
+    void setsize (size_type _n)
     {
       this->n = _n;
     }
@@ -509,7 +520,7 @@ namespace Dune {
     }
 
     //! get size
-    int getsize ()
+    size_type getsize ()
     {
       return this->n;
     }
@@ -547,12 +558,14 @@ namespace Dune {
     //! make iterators available as types
     typedef typename compressed_base_array_unmanaged<B,A>::const_iterator ConstIterator;
 
+    //! The type for the index access
+    typedef typename A::size_type size_type;
 
     //===== assignment from scalar
 
     compressed_block_vector_unmanaged& operator= (const field_type& k)
     {
-      for (int i=0; i<this->n; i++)
+      for (size_type i=0; i<this->n; i++)
         (this->p)[i] = k;
       return *this;
     }
@@ -567,7 +580,7 @@ namespace Dune {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
 #endif
-      for (int i=0; i<this->n; ++i) (this->p)[i] += y[(this->j)[i]];
+      for (size_type i=0; i<this->n; ++i) (this->p)[i] += y[(this->j)[i]];
       return *this;
     }
 
@@ -578,7 +591,7 @@ namespace Dune {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
 #endif
-      for (int i=0; i<this->n; ++i) (this->p)[i] -= y[(this->j)[i]];
+      for (size_type i=0; i<this->n; ++i) (this->p)[i] -= y[(this->j)[i]];
       return *this;
     }
 
@@ -589,21 +602,21 @@ namespace Dune {
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
 #endif
-      for (int i=0; i<this->n; ++i) (this->p)[i].axpy(a,y[(this->j)[i]]);
+      for (size_type i=0; i<this->n; ++i) (this->p)[i].axpy(a,y[(this->j)[i]]);
       return *this;
     }
 
     //! vector space multiplication with scalar
     compressed_block_vector_unmanaged& operator*= (const field_type& k)
     {
-      for (int i=0; i<this->n; ++i) (this->p)[i] *= k;
+      for (size_type i=0; i<this->n; ++i) (this->p)[i] *= k;
       return *this;
     }
 
     //! vector space division by scalar
     compressed_block_vector_unmanaged& operator/= (const field_type& k)
     {
-      for (int i=0; i<this->n; ++i) (this->p)[i] /= k;
+      for (size_type i=0; i<this->n; ++i) (this->p)[i] /= k;
       return *this;
     }
 
@@ -617,7 +630,7 @@ namespace Dune {
       if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
 #endif
       field_type sum=0;
-      for (int i=0; i<this->n; ++i)
+      for (size_type i=0; i<this->n; ++i)
         sum += (this->p)[i] * y[(this->j)[i]];
       return sum;
     }
@@ -629,7 +642,7 @@ namespace Dune {
     double one_norm () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (this->p)[i].one_norm();
+      for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].one_norm();
       return sum;
     }
 
@@ -637,7 +650,7 @@ namespace Dune {
     double one_norm_real () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (this->p)[i].one_norm_real();
+      for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].one_norm_real();
       return sum;
     }
 
@@ -645,7 +658,7 @@ namespace Dune {
     double two_norm () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
+      for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
       return sqrt(sum);
     }
 
@@ -653,7 +666,7 @@ namespace Dune {
     double two_norm2 () const
     {
       double sum=0;
-      for (int i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
+      for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
       return sum;
     }
 
@@ -661,7 +674,7 @@ namespace Dune {
     double infinity_norm () const
     {
       double max=0;
-      for (int i=0; i<this->n; ++i) max = std::max(max,(this->p)[i].infinity_norm());
+      for (size_type i=0; i<this->n; ++i) max = std::max(max,(this->p)[i].infinity_norm());
       return max;
     }
 
@@ -669,7 +682,7 @@ namespace Dune {
     double infinity_norm_real () const
     {
       double max=0;
-      for (int i=0; i<this->n; ++i) max = std::max(max,(this->p)[i].infinity_norm_real());
+      for (size_type i=0; i<this->n; ++i) max = std::max(max,(this->p)[i].infinity_norm_real());
       return max;
     }
 
@@ -677,16 +690,16 @@ namespace Dune {
     //===== sizes
 
     //! number of blocks in the vector (are of size 1 here)
-    int N () const
+    size_type N () const
     {
       return this->n;
     }
 
     //! dimension of the vector space
-    int dim () const
+    size_type dim () const
     {
-      int d=0;
-      for (int i=0; i<this->n; i++)
+      size_type d=0;
+      for (size_type i=0; i<this->n; i++)
         d += (this->p)[i].dim();
       return d;
     }
@@ -701,7 +714,7 @@ namespace Dune {
     bool includesindexset (const V& y)
     {
       typename V::Iterator e=y.end();
-      for (int i=0; i<this->n; i++)
+      for (size_type i=0; i<this->n; i++)
         if (y.find((this->j)[i])==e)
           return false;
       return true;
@@ -741,6 +754,9 @@ namespace Dune {
     //! export the allocator type
     typedef A allocator_type;
 
+    //! The type for the index access
+    typedef typename A::size_type size_type;
+
     //! increment block level counter
     enum {
       //! The number of block level this vector contains.
@@ -760,7 +776,7 @@ namespace Dune {
     {       }
 
     //! make array from given pointers and size
-    CompressedBlockVectorWindow (B* _p, int* _j, int _n)
+    CompressedBlockVectorWindow (B* _p, size_type* _j, size_type _n)
     {
       this->n = _n;
       this->p = _p;
@@ -799,8 +815,8 @@ namespace Dune {
       if (&a!=this)     // check if this and a are different objects
       {
         // copy data
-        for (int i=0; i<this->n; i++) this->p[i]=a.p[i];
-        for (int i=0; i<this->n; i++) this->j[i]=a.j[i];
+        for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
+        for (size_type i=0; i<this->n; i++) this->j[i]=a.j[i];
       }
       return *this;
     }
@@ -823,7 +839,7 @@ namespace Dune {
     //===== window manipulation methods
 
     //! set size and pointer
-    void set (int _n, B* _p, int* _j)
+    void set (size_type _n, B* _p, size_type* _j)
     {
       this->n = _n;
       this->p = _p;
@@ -831,7 +847,7 @@ namespace Dune {
     }
 
     //! set size only
-    void setsize (int _n)
+    void setsize (size_type _n)
     {
       this->n = _n;
     }
@@ -843,7 +859,7 @@ namespace Dune {
     }
 
     //! set pointer only
-    void setindexptr (int* _j)
+    void setindexptr (size_type* _j)
     {
       this->j = _j;
     }
@@ -855,13 +871,13 @@ namespace Dune {
     }
 
     //! get pointer
-    int* getindexptr ()
+    size_type* getindexptr ()
     {
       return this->j;
     }
 
     //! get size
-    int getsize ()
+    size_type getsize ()
     {
       return this->n;
     }
diff --git a/istl/io.hh b/istl/io.hh
index af7502ffe..9218206ac 100644
--- a/istl/io.hh
+++ b/istl/io.hh
@@ -107,16 +107,18 @@ namespace Dune {
 
   //! print one row of a matrix
   template<class M>
-  void print_row (std::ostream& s, const M& A, int I, int J, int therow, int width, int precision)
+  void print_row (std::ostream& s, const M& A, typename M::size_type I,
+                  typename M::size_type J, typename M::size_type therow,
+                  int width, int precision)
   {
-    int i0=I;
-    for (int i=0; i<A.N(); i++)
+    typename M::size_type i0=I;
+    for (typename M::size_type i=0; i<A.N(); i++)
     {
       if (therow>=i0 && therow<i0+A.rowdim(i))
       {
         // the row is in this block row !
-        int j0=J;
-        for (int j=0; j<A.M(); j++)
+        typename M::size_type j0=J;
+        for (typename M::size_type j=0; j<A.M(); j++)
         {
           // find this block
           typename M::ConstColIterator it = A[i].find(j);
@@ -138,9 +140,13 @@ namespace Dune {
 
   //! print one row of a matrix, specialization for FieldMatrix
   template<class K, int n, int m>
-  void print_row (std::ostream& s, const FieldMatrix<K,n,m>& A, int I, int J, int therow, int width, int precision)
+  void print_row (std::ostream& s, const FieldMatrix<K,n,m>& A,
+                  typename FieldMatrix<K,n,m>::size_type I, typename FieldMatrix<K,n,m>::size_type J,
+                  typename FieldMatrix<K,n,m>::size_type therow, int width, int precision)
   {
-    for (int i=0; i<n; i++)
+    typedef typename FieldMatrix<K,n,m>::size_type size_type;
+
+    for (size_type i=0; i<n; i++)
       if (I+i==therow)
         for (int j=0; j<m; j++)
         {
@@ -152,7 +158,9 @@ namespace Dune {
 
   //! print one row of a matrix, specialization for FieldMatrix<K,1,1>
   template<class K>
-  void print_row (std::ostream& s, const FieldMatrix<K,1,1>& A, int I, int J, int therow, int width, int precision)
+  void print_row (std::ostream& s, const FieldMatrix<K,1,1>& A, typename FieldMatrix<K,1,1>::size_type I,
+                  typename FieldMatrix<K,1,1>::size_type J, typename FieldMatrix<K,1,1>::size_type therow,
+                  int width, int precision)
   {
     if (I==therow)
     {
@@ -181,7 +189,7 @@ namespace Dune {
       << "]" << std::endl;
 
     // print all rows
-    for (int i=0; i<A.rowdim(); i++)
+    for (typename M::size_type i=0; i<A.rowdim(); i++)
     {
       s << rowtext;            // start a new row
       s << " ";                // space in front of each entry
-- 
GitLab