diff --git a/dune/istl/matrix.hh b/dune/istl/matrix.hh
index 946d28ea4c678b52efaeb19bff2ec1c6e80f0bb5..e8f8e156322647610259245c9fe1c565a35bbdfd 100644
--- a/dune/istl/matrix.hh
+++ b/dune/istl/matrix.hh
@@ -738,9 +738,9 @@ namespace MatrixImp
 
     /** \brief Return the transpose of the matrix */
     Matrix transpose() const {
-      Matrix out(N(), M());
-      for (size_type i=0; i<M(); i++)
-        for (size_type j=0; j<N(); j++)
+      Matrix out(M(), N());
+      for (size_type i=0; i<N(); i++)
+        for (size_type j=0; j<M(); j++)
           out[j][i] = (*this)[i][j];
 
       return out;