]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Don't allocate memory if the line is empty.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 May 2005 22:29:29 +0000 (22:29 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 May 2005 22:29:29 +0000 (22:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@10600 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/petsc_matrix_base.cc

index a568ba55eb7bc914114a25ec27e72ac99153bb95..7e5f0c9c03fb59150b502175f28e270ee53bcfae 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2004 by the deal.II authors
+//    Copyright (C) 2004, 2005 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -62,11 +62,20 @@ namespace PETScWrappers
       ierr = MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values);
       AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
 
-                                       // copy it into our caches
-      colnum_cache.reset (new std::vector<unsigned int> (colnums,
-                                                         colnums+ncols));
-      value_cache.reset (new std::vector<PetscScalar> (values, values+ncols));
-
+                                       // copy it into our caches if the line
+                                       // isn't empty
+      if (ncols != 0)
+        {
+          colnum_cache.reset (new std::vector<unsigned int> (colnums,
+                                                             colnums+ncols));
+          value_cache.reset (new std::vector<PetscScalar> (values, values+ncols));
+        }
+      else
+        {
+          colnum_cache.reset ();
+          value_cache.reset ();
+        }
+      
                                        // and finally restore the matrix
       ierr = MatRestoreRow(*matrix, this->a_row, &ncols, &colnums, &values);
       AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));

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.