]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add functions to check whether an object looks initialized or not.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 25 May 1998 14:35:50 +0000 (14:35 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 25 May 1998 14:35:50 +0000 (14:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@348 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/dfmatrix.h
deal.II/lac/include/lac/dvector.h
deal.II/lac/source/dfmatrix.cc
deal.II/lac/source/dvector.cc

index 23da542047751018beae5de7994fce54b390208d..4a579bc3d6a89dce23714611bf86113c19c360f3 100644 (file)
@@ -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;
+
                                     //@}
     
     
index 77cb3a749ccc27b55295e4ad0f9f94ce246869b9..3bd02e73a69b4e1e6799c148369bf62b598d5fd7 100644 (file)
@@ -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
index 4f90cc672e29905b8bf1914af9e48f6ee422daa8..c3034a894f5dc23b81ca440995944462321a305b 100644 (file)
@@ -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<nn*mm)
index e83d8cd10ad014cf598b4516d5673fd46e283d9a..4b67a950ed0581a3f476dd156a726fc389a467d3 100644 (file)
@@ -101,6 +101,18 @@ void dVector::clear () {
 }
 
 
+
+bool dVector::all_zero () const {
+  const_iterator p = begin(),
+                e = end();
+  while (p!=e)
+    if (*p++ != 0.0)
+      return false;
+  return true;
+};
+
+
+
 double dVector::operator * (const dVector& v) const
 {
   if (&v == this)

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.