From: Wolfgang Bangerth Date: Mon, 25 May 1998 14:35:50 +0000 (+0000) Subject: Add functions to check whether an object looks initialized or not. X-Git-Tag: v8.0.0~22906 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aeab689f28362fc2ee176f9557c4e53dcee6aedd;p=dealii.git Add functions to check whether an object looks initialized or not. git-svn-id: https://svn.dealii.org/trunk@348 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/dfmatrix.h b/deal.II/lac/include/lac/dfmatrix.h index 23da542047..4a579bc3d6 100644 --- a/deal.II/lac/include/lac/dfmatrix.h +++ b/deal.II/lac/include/lac/dfmatrix.h @@ -141,6 +141,17 @@ class dFMatrix * Inquire Dimension (Col) . returns Number of Columns */ unsigned int n () const { return dim_range; } + + /** + * Return whether the matrix contains only + * elements with value zero. This function + * is mainly for internal consistency + * check and should seldomly be used when + * not in debug mode since it uses quite + * some time. + */ + bool all_zero () const; + //@} diff --git a/deal.II/lac/include/lac/dvector.h b/deal.II/lac/include/lac/dvector.h index 77cb3a749c..3bd02e73a6 100644 --- a/deal.II/lac/include/lac/dvector.h +++ b/deal.II/lac/include/lac/dvector.h @@ -187,6 +187,16 @@ class dVector : public VectorBase */ unsigned int size () const; + /** + * Return whether the vector contains only + * elements with value zero. This function + * is mainly for internal consistency + * check and should seldomly be used when + * not in debug mode since it uses quite + * some time. + */ + bool all_zero () const; + /** * Make the #dVector# class a bit like the * #vector<># class of the C++ standard diff --git a/deal.II/lac/source/dfmatrix.cc b/deal.II/lac/source/dfmatrix.cc index 4f90cc672e..c3034a894f 100644 --- a/deal.II/lac/source/dfmatrix.cc +++ b/deal.II/lac/source/dfmatrix.cc @@ -30,6 +30,19 @@ dFMatrix::~dFMatrix () delete[] val; } + +bool dFMatrix::all_zero () const { + const double *p = &val[0], + *e = &val[n()*m()]; + while (p!=e) + if (*p++ != 0.0) + return false; + + return true; +}; + + + void dFMatrix::reinit (const unsigned int mm, const unsigned int nn) { if (val_size