]> https://gitweb.dealii.org/ - dealii.git/commitdiff
replace stupid integer product by the more reasonable test that both are nonzero
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 17 Aug 2010 08:58:48 +0000 (08:58 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 17 Aug 2010 08:58:48 +0000 (08:58 +0000)
this allows us to use copy_from with sparsity patterns of size 65536

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

deal.II/lac/source/sparsity_pattern.cc

index 500bfac7a404cffc12f9338913d2542dee8962ce..2756701c506fba482425cc6798e6bf48a5aec843 100644 (file)
@@ -568,12 +568,9 @@ SparsityPattern::copy_from (const CSP &csp,
   std::vector<unsigned int> row_lengths (csp.n_rows());
   for (unsigned int i=0; i<csp.n_rows(); ++i)
     {
-      unsigned int additional_diagonal = 0;
-      if (do_diag_optimize)
-       if (csp.exists(i,i) == false)
-         additional_diagonal = 1;
-
-      row_lengths[i] = csp.row_length(i) + additional_diagonal;
+      row_lengths[i] = csp.row_length(i);
+      if (do_diag_optimize && !csp.exists(i,i))
+       ++row_lengths[i];
     }
   reinit (csp.n_rows(), csp.n_cols(), row_lengths, do_diag_optimize);
 
@@ -583,7 +580,7 @@ SparsityPattern::copy_from (const CSP &csp,
                                   // quadratic, then we already have
                                   // the diagonal element
                                   // preallocated
-  if (n_rows() * n_cols() > 0)
+  if (n_rows() != 0 && n_cols() != 0)
     for (unsigned int row = 0; row<csp.n_rows(); ++row)
       {
        unsigned int *cols = &colnums[rowstart[row]] + (do_diag_optimize ? 1 : 0);

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.