]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Simplify function. The shortcut doesn't reliably work because it assumes that
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 8 Jan 2013 19:05:05 +0000 (19:05 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 8 Jan 2013 19:05:05 +0000 (19:05 +0000)
neither of the two iterators is past-the-end. If we were to check this in the
shortcut, then this would negate the benefits of the shortcut to begin with.

git-svn-id: https://svn.dealii.org/trunk@27975 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/sparse_matrix.h

index 96b39d28ff0140ed1e91d00811c8282243a8dc3b..0eaada198cd4c27aaff0272a5f62c6dae28a0c7e 100644 (file)
@@ -1,7 +1,7 @@
 //---------------------------------------------------------------------------
 //    $Id$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -2236,21 +2236,17 @@ namespace SparseMatrixIterators
     Assert (&accessor.get_matrix() == &other.accessor.get_matrix(),
             ExcInternalError());
 
-    if ((*this)->row() == other->row())
-      return ((*this)->index() - other->index());
-    else
-      {
-        const SparsityPattern &sparsity = accessor.get_matrix().get_sparsity_pattern();
-        const unsigned int this_position
-        = sparsity.get_rowstart_indices()[(*this)->row()] + (*this)->index();
-        const unsigned int other_position
-        = sparsity.get_rowstart_indices()[other->row()] + other->index();
-
-        return (this_position - other_position);
-      }
+    const SparsityPattern &sparsity = accessor.get_matrix().get_sparsity_pattern();
+    const unsigned int this_position
+      = sparsity.get_rowstart_indices()[(*this)->row()] + (*this)->index();
+    const unsigned int other_position
+      = sparsity.get_rowstart_indices()[other->row()] + other->index();
+
+    return (this_position - other_position);
   }
 
 
+
   template <typename number, bool Constness>
   inline
   Iterator<number,Constness>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.