From 4d1b7ce9890309eb1316ef82325b08dd8412448e Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 1 Mar 1999 12:54:39 +0000 Subject: [PATCH] Add a function which tells us whether a SparseMatrix is empty or not. git-svn-id: https://svn.dealii.org/trunk@934 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_matrix.h | 8 ++++++++ deal.II/lac/include/lac/sparse_matrix.templates.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index c686b4fa00..90517d7c2d 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -449,6 +449,14 @@ class SparseMatrix */ virtual void clear (); + /** + * Return whether the object is empty. It + * is empty if either both dimensions + * are zero or no #SparseMatrixStruct# + * is associated. + */ + bool empty () const; + /** * Return the dimension of the image space. * To remember: the matrix is of dimension diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index b12f40b4fa..f5742cc5d2 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -90,6 +90,18 @@ SparseMatrix::clear () { +template +bool +SparseMatrix::empty () const +{ + if (cols == 0) + return true; + else + return cols->empty(); +}; + + + template unsigned int SparseMatrix::n_nonzero_elements () const { -- 2.39.5