]> https://gitweb.dealii.org/ - dealii.git/commitdiff
SparseMatrix<number>::n_actually_nonzero_elements () counts all entries that are...
authorRalf Hartmann <Ralf.Hartmann@dlr.de>
Wed, 22 Nov 2000 14:47:03 +0000 (14:47 +0000)
committerRalf Hartmann <Ralf.Hartmann@dlr.de>
Wed, 22 Nov 2000 14:47:03 +0000 (14:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@3496 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 3e59f49bab48369130a8675c70bb3cb14f48c3e4..57902399df61c02e4bbdff16199c878810361420 100644 (file)
@@ -219,6 +219,20 @@ class SparseMatrix : public Subscriptor
                                      * be zero, it is counted anyway.
                                      */
     unsigned int n_nonzero_elements () const;
+
+                                    /**
+                                     * Return the number of actually
+                                     * nonzero elements of this
+                                     * matrix.
+                                     *
+                                     * Note, that this function does
+                                     * (in contrary to the
+                                     * @p{n_nonzero_elements}) NOT
+                                     * count all entries of the
+                                     * sparsity pattern but only the
+                                     * ones that are nonzero.
+                                     */
+    unsigned int n_actually_nonzero_elements () const;
     
                                     /**
                                      * Set the element @p{(i,j)} to @p{value}.
index 40fbc14c59c4d15f0c1fe6a5e4dfc0594ea51e21..140867958541fb39c23b3256d4af537a50c09bf1 100644 (file)
@@ -152,6 +152,16 @@ SparseMatrix<number>::n_nonzero_elements () const
 };
 
 
+template <typename number>
+unsigned int
+SparseMatrix<number>::n_actually_nonzero_elements () const
+{
+  Assert (cols != 0, ExcMatrixNotInitialized());
+  return count_if(&val[0], &val[n_nonzero_elements ()],
+                 bind2nd(not_equal_to<double>(), 0));
+};
+
+
 template <typename number>
 template <typename somenumber>
 SparseMatrix<number> &

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.