]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Cleanup of operator = (double).
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 9 Dec 2009 18:12:05 +0000 (18:12 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 9 Dec 2009 18:12:05 +0000 (18:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@20220 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparse_matrix.h
deal.II/lac/include/lac/block_sparse_matrix.templates.h
deal.II/lac/include/lac/full_matrix.h
deal.II/lac/include/lac/petsc_block_sparse_matrix.h
deal.II/lac/include/lac/petsc_parallel_block_sparse_matrix.h
deal.II/lac/include/lac/trilinos_block_sparse_matrix.h
deal.II/lac/source/petsc_block_sparse_matrix.cc
deal.II/lac/source/petsc_parallel_block_sparse_matrix.cc
deal.II/lac/source/trilinos_block_sparse_matrix.cc

index f23ffa5c90b121f9d8ed1a784baa1c31a0323394..205441ecf9c31c287a52be1574bea13ea55a45d3 100644 (file)
@@ -50,7 +50,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
                                       * access to its own typedefs.
                                       */
     typedef BlockMatrixBase<SparseMatrix<number> > BaseClass;
-    
+
                                      /**
                                       * Typedef the type of the underlying
                                       * matrix.
@@ -120,10 +120,10 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
                                      * Destructor.
                                      */
     virtual ~BlockSparseMatrix ();
-    
-    
 
-                                    /** 
+
+
+                                    /**
                                      * Pseudo copy operator only copying
                                      * empty objects. The sizes of the block
                                      * matrices need to be the same.
@@ -131,22 +131,22 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
     BlockSparseMatrix &
     operator = (const BlockSparseMatrix &);
 
-                                    /**
+                                     /**
                                      * This operator assigns a scalar to a
                                      * matrix. Since this does usually not
                                      * make much sense (should we set all
-                                     * matrix entries to this value? Only the
-                                     * nonzero entries of the sparsity
+                                     * matrix entries to this value? Only
+                                     * the nonzero entries of the sparsity
                                      * pattern?), this operation is only
                                      * allowed if the actual value to be
                                      * assigned is zero. This operator only
                                      * exists to allow for the obvious
-                                     * notation <tt>matrix=0</tt>, which sets
-                                     * all elements of the matrix to zero,
-                                     * but keep the sparsity pattern
+                                     * notation <tt>matrix=0</tt>, which
+                                     * sets all elements of the matrix to
+                                     * zero, but keep the sparsity pattern
                                      * previously used.
                                      */
-    BlockSparseMatrix<number> &
+    BlockSparseMatrix &
     operator = (const double d);
 
                                     /**
@@ -162,7 +162,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
                                      * object to have no blocks at all.
                                      */
     void clear ();
-    
+
                                     /**
                                      * Reinitialize the sparse matrix
                                      * with the given sparsity
@@ -209,7 +209,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
                                      * (with absolute value larger than
                                      * threshold) of all the blocks.
                                      */
-    unsigned int n_actually_nonzero_elements (const double threshold = 0.0) const;    
+    unsigned int n_actually_nonzero_elements (const double threshold = 0.0) const;
 
                                     /**
                                      * Matrix-vector multiplication:
@@ -254,7 +254,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
     template <typename nonblock_number>
     void vmult (Vector<nonblock_number>       &dst,
                 const Vector<nonblock_number> &src) const;
-    
+
                                     /**
                                      * Matrix-vector multiplication:
                                      * let $dst = M^T*src$ with $M$
@@ -266,7 +266,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
     template <typename block_number>
     void Tvmult (BlockVector<block_number>       &dst,
                  const BlockVector<block_number> &src) const;
-  
+
                                     /**
                                      * Matrix-vector
                                      * multiplication. Just like the
@@ -301,7 +301,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
     template <typename nonblock_number>
     void Tvmult (Vector<nonblock_number>       &dst,
                  const Vector<nonblock_number> &src) const;
-    
+
                                     /**
                                      * Apply the Jacobi
                                      * preconditioner, which
@@ -396,7 +396,7 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
                                      */
     const BlockSparsityPattern &
     get_sparsity_pattern () const;
-    
+
                                     /**
                                      * Determine an estimate for the
                                      * memory consumption (in bytes)
@@ -406,12 +406,12 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
 
                                     /** @addtogroup Exceptions
                                      * @{ */
-    
+
                                      /**
                                       * Exception
                                       */
     DeclException0 (ExcBlockDimensionMismatch);
-                                    //@}    
+                                    //@}
   private:
                                     /**
                                      * Pointer to the block sparsity
@@ -432,6 +432,22 @@ class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
 
 
 
+template <typename number>
+inline
+BlockSparseMatrix<number> &
+BlockSparseMatrix<number>::operator = (const double d)
+{
+  Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+  for (unsigned int r=0; r<this->n_block_rows(); ++r)
+    for (unsigned int c=0; c<this->n_block_cols(); ++c)
+      this->block(r,c) = d;
+
+  return *this;
+}
+
+
+
 template <typename number>
 template <typename block_number>
 inline
@@ -441,7 +457,7 @@ BlockSparseMatrix<number>::vmult (BlockVector<block_number>       &dst,
 {
   BaseClass::vmult_block_block (dst, src);
 }
-  
+
 
 
 template <typename number>
@@ -454,7 +470,7 @@ BlockSparseMatrix<number>::vmult (BlockVector<block_number>     &dst,
 {
   BaseClass::vmult_block_nonblock (dst, src);
 }
-  
+
 
 
 template <typename number>
@@ -467,7 +483,7 @@ BlockSparseMatrix<number>::vmult (Vector<nonblock_number>         &dst,
 {
   BaseClass::vmult_nonblock_block (dst, src);
 }
-  
+
 
 
 template <typename number>
@@ -481,6 +497,7 @@ BlockSparseMatrix<number>::vmult (Vector<nonblock_number>       &dst,
 }
 
 
+
 template <typename number>
 template <typename block_number>
 inline
@@ -490,7 +507,7 @@ BlockSparseMatrix<number>::Tvmult (BlockVector<block_number>       &dst,
 {
   BaseClass::Tvmult_block_block (dst, src);
 }
-  
+
 
 
 template <typename number>
@@ -503,7 +520,7 @@ BlockSparseMatrix<number>::Tvmult (BlockVector<block_number>     &dst,
 {
   BaseClass::Tvmult_block_nonblock (dst, src);
 }
-  
+
 
 
 template <typename number>
@@ -516,7 +533,7 @@ BlockSparseMatrix<number>::Tvmult (Vector<nonblock_number>         &dst,
 {
   BaseClass::Tvmult_nonblock_block (dst, src);
 }
-  
+
 
 
 template <typename number>
@@ -530,8 +547,10 @@ BlockSparseMatrix<number>::Tvmult (Vector<nonblock_number>       &dst,
 }
 
 
+
 template <typename number>
 template <class BlockVectorType>
+inline
 void
 BlockSparseMatrix<number>::
 precondition_Jacobi (BlockVectorType       &dst,
@@ -553,8 +572,10 @@ precondition_Jacobi (BlockVectorType       &dst,
 }
 
 
+
 template <typename number>
 template <typename number2>
+inline
 void
 BlockSparseMatrix<number>::
 precondition_Jacobi (Vector<number2>       &dst,
index d6b84c64d599ca4c561707103ea4aae677a48c5d..078a7c10523564cfa5a3ff20af057660f90ad614 100644 (file)
@@ -68,21 +68,6 @@ operator = (const BlockSparseMatrix<number> &m)
   return *this;
 }
 
-
-template <typename number>
-BlockSparseMatrix<number> &
-BlockSparseMatrix<number>::operator = (const double d)
-{
-  Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
-  
-  for (unsigned int r=0; r<this->n_block_rows(); ++r)
-    for (unsigned int c=0; c<this->n_block_cols(); ++c)
-      this->block(r,c) = d;
-
-  return *this;
-}
-
 
 
 template <typename number>
index 1d4f113acf6be7f80e6ed3091733407427463008..ed3e2c044e2a88f6a9c5a6adad95154b0f14e3db 100644 (file)
@@ -1365,7 +1365,7 @@ FullMatrix<number>::operator = (const number d)
   Assert (d==number(0), ExcScalarAssignmentOnlyForZeroValue());
 
   if (this->n_elements() != 0)
-    std::fill_n (this->val, this->n_elements(), number());
+    memset (this->val, 0, this->n_elements()*sizeof(number));
 
   return *this;
 }
index edb9648a63be9ba4ba81d30c2915f5d0c66d40f6..03c93e15c165793bb8aa565c4b29c0d701d61953 100644 (file)
@@ -32,7 +32,7 @@ DEAL_II_NAMESPACE_OPEN
 
 namespace PETScWrappers
 {
-  
+
 /*! @addtogroup PETScWrappers
  *@{
  */
@@ -66,7 +66,7 @@ namespace PETScWrappers
                                         * access to its own typedefs.
                                         */
       typedef BlockMatrixBase<SparseMatrix> BaseClass;
-    
+
                                        /**
                                         * Typedef the type of the underlying
                                         * matrix.
@@ -114,7 +114,7 @@ namespace PETScWrappers
                                         */
       ~BlockSparseMatrix ();
 
-                                       /** 
+                                       /**
                                         * Pseudo copy operator only copying
                                         * empty objects. The sizes of the block
                                         * matrices need to be the same.
@@ -168,7 +168,7 @@ namespace PETScWrappers
                                         */
       void reinit (const unsigned int n_block_rows,
                    const unsigned int n_block_columns);
-      
+
                                        /**
                                         * This function collects the
                                         * sizes of the sub-objects and
@@ -220,7 +220,7 @@ namespace PETScWrappers
                                         */
       void vmult (Vector       &dst,
                   const Vector &src) const;
-    
+
                                        /**
                                         * Matrix-vector multiplication:
                                         * let $dst = M^T*src$ with $M$
@@ -231,7 +231,7 @@ namespace PETScWrappers
                                         */
       void Tvmult (BlockVector       &dst,
                    const BlockVector &src) const;
-  
+
                                        /**
                                         * Matrix-vector
                                         * multiplication. Just like the
@@ -260,7 +260,7 @@ namespace PETScWrappers
                                         * only one block.
                                         */
       void Tvmult (Vector       &dst,
-                   const Vector &src) const;    
+                   const Vector &src) const;
 
                                        /**
                                         * Make the clear() function in the
@@ -268,11 +268,11 @@ namespace PETScWrappers
                                         * protected.
                                         */
       using BlockMatrixBase<SparseMatrix>::clear;
-      
+
                                       /** @addtogroup Exceptions
                                        * @{
                                        */
-      
+
                                        /**
                                         * Exception
                                         */
@@ -296,6 +296,21 @@ namespace PETScWrappers
 
 // ------------- inline and template functions -----------------
 
+  inline
+  BlockSparseMatrix &
+  BlockSparseMatrix::operator = (const double d)
+  {
+    Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+    for (unsigned int r=0; r<this->n_block_rows(); ++r)
+      for (unsigned int c=0; c<this->n_block_cols(); ++c)
+       this->block(r,c) = d;
+
+    return *this;
+  }
+
+
+
   inline
   void
   BlockSparseMatrix::vmult (BlockVector       &dst,
@@ -303,7 +318,7 @@ namespace PETScWrappers
   {
     BaseClass::vmult_block_block (dst, src);
   }
-  
+
 
 
   inline
@@ -313,7 +328,7 @@ namespace PETScWrappers
   {
     BaseClass::vmult_block_nonblock (dst, src);
   }
-  
+
 
 
   inline
@@ -323,7 +338,7 @@ namespace PETScWrappers
   {
     BaseClass::vmult_nonblock_block (dst, src);
   }
-  
+
 
 
   inline
@@ -342,7 +357,7 @@ namespace PETScWrappers
   {
     BaseClass::Tvmult_block_block (dst, src);
   }
-  
+
 
 
   inline
@@ -352,7 +367,7 @@ namespace PETScWrappers
   {
     BaseClass::Tvmult_block_nonblock (dst, src);
   }
-  
+
 
 
   inline
@@ -362,7 +377,7 @@ namespace PETScWrappers
   {
     BaseClass::Tvmult_nonblock_block (dst, src);
   }
-  
+
 
 
   inline
@@ -372,7 +387,7 @@ namespace PETScWrappers
   {
     BaseClass::Tvmult_nonblock_nonblock (dst, src);
   }
-  
+
 }
 
 DEAL_II_NAMESPACE_CLOSE
index f4489cb5b2cbb7ebe19c566a6458a60d07d6b7ec..8553f6f43e56d6ad7d922d5f1cbd68ffe155973c 100644 (file)
@@ -36,7 +36,7 @@ namespace PETScWrappers
 
 /*! @addtogroup PETScWrappers
  *@{
- */   
+ */
 
 /**
  * Blocked sparse matrix based on the PETScWrappers::SparseMatrix class. This
@@ -67,7 +67,7 @@ namespace PETScWrappers
                                           * access to its own typedefs.
                                           */
         typedef BlockMatrixBase<SparseMatrix> BaseClass;
-    
+
                                          /**
                                           * Typedef the type of the underlying
                                           * matrix.
@@ -115,7 +115,7 @@ namespace PETScWrappers
                                           */
         ~BlockSparseMatrix ();
 
-                                         /** 
+                                         /**
                                           * Pseudo copy operator only copying
                                           * empty objects. The sizes of the
                                           * block matrices need to be the
@@ -141,7 +141,7 @@ namespace PETScWrappers
                                           * previously used.
                                           */
         BlockSparseMatrix &
-        operator = (const PetscScalar d);
+        operator = (const double d);
 
                                          /**
                                           * Resize the matrix, by setting
@@ -170,7 +170,7 @@ namespace PETScWrappers
                                           * she desires.
                                           */
         void reinit (const unsigned int n_block_rows,
-                     const unsigned int n_block_columns);      
+                     const unsigned int n_block_columns);
 
                                          /**
                                           * Matrix-vector multiplication:
@@ -209,7 +209,7 @@ namespace PETScWrappers
                                           */
         void vmult (Vector       &dst,
                     const Vector &src) const;
-    
+
                                          /**
                                           * Matrix-vector multiplication:
                                           * let $dst = M^T*src$ with $M$
@@ -220,7 +220,7 @@ namespace PETScWrappers
                                           */
         void Tvmult (BlockVector       &dst,
                      const BlockVector &src) const;
-  
+
                                          /**
                                           * Matrix-vector
                                           * multiplication. Just like the
@@ -249,7 +249,7 @@ namespace PETScWrappers
                                           * only one block.
                                           */
         void Tvmult (Vector       &dst,
-                     const Vector &src) const;    
+                     const Vector &src) const;
 
                                          /**
                                           * This function collects the
@@ -264,7 +264,7 @@ namespace PETScWrappers
                                           * the sub-objects.
                                           */
         void collect_sizes ();
-        
+
                                          /**
                                           * Return a reference to the MPI
                                           * communicator object in use with
@@ -286,6 +286,21 @@ namespace PETScWrappers
 
 // ------------- inline and template functions -----------------
 
+    inline
+    BlockSparseMatrix &
+    BlockSparseMatrix::operator = (const double d)
+    {
+      Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+      for (unsigned int r=0; r<this->n_block_rows(); ++r)
+       for (unsigned int c=0; c<this->n_block_cols(); ++c)
+         this->block(r,c) = d;
+
+      return *this;
+    }
+
+
+
     inline
     void
     BlockSparseMatrix::vmult (BlockVector       &dst,
@@ -293,7 +308,7 @@ namespace PETScWrappers
     {
       BaseClass::vmult_block_block (dst, src);
     }
-  
+
 
 
     inline
@@ -303,7 +318,7 @@ namespace PETScWrappers
     {
       BaseClass::vmult_block_nonblock (dst, src);
     }
-  
+
 
 
     inline
@@ -313,7 +328,7 @@ namespace PETScWrappers
     {
       BaseClass::vmult_nonblock_block (dst, src);
     }
-  
+
 
 
     inline
@@ -332,7 +347,7 @@ namespace PETScWrappers
     {
       BaseClass::Tvmult_block_block (dst, src);
     }
-  
+
 
 
     inline
@@ -342,7 +357,7 @@ namespace PETScWrappers
     {
       BaseClass::Tvmult_block_nonblock (dst, src);
     }
-  
+
 
 
     inline
@@ -352,7 +367,7 @@ namespace PETScWrappers
     {
       BaseClass::Tvmult_nonblock_block (dst, src);
     }
-  
+
 
 
     inline
@@ -362,9 +377,9 @@ namespace PETScWrappers
     {
       BaseClass::Tvmult_nonblock_nonblock (dst, src);
     }
-  
+
   }
-  
+
 }
 
 
index 105309562b1e4bfe4021f74064726d024e4cb9d8..7dadd219e3ad7223a0ca1ca973270292000ad84b 100644 (file)
@@ -645,6 +645,23 @@ namespace TrilinosWrappers
 
 // ------------- inline and template functions -----------------
 
+
+
+  inline
+  BlockSparseMatrix &
+  BlockSparseMatrix::operator = (const double d)
+  {
+    Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+    for (unsigned int r=0; r<this->n_block_rows(); ++r)
+      for (unsigned int c=0; c<this->n_block_cols(); ++c)
+       this->block(r,c) = d;
+
+    return *this;
+  }
+
+
+
   inline
   bool
   BlockSparseMatrix::is_compressed () const
index ca306e1db720825bac80971637a7fac8e217c768..72d2de632896dba3794dbffe2fa55e02f6d95865 100644 (file)
@@ -39,18 +39,6 @@ namespace PETScWrappers
   }
 
 
-
-  BlockSparseMatrix &
-  BlockSparseMatrix::operator = (const double d)
-  {
-    for (unsigned int r=0; r<this->n_block_rows(); ++r)
-      for (unsigned int c=0; c<this->n_block_cols(); ++c)
-        this->block(r,c) = d;
-
-    return *this;
-  }
-
-
   void
   BlockSparseMatrix::
   reinit (const unsigned int n_block_rows,
index 677f0eaeaeec0cb67a8f8b2fae264051a315de67..ff9064a5228154a98db24513865787dfdf55fbe9 100644 (file)
@@ -42,18 +42,6 @@ namespace PETScWrappers
     }
 
 
-
-    BlockSparseMatrix &
-    BlockSparseMatrix::operator = (const PetscScalar d)
-    {
-      for (unsigned int r=0; r<this->n_block_rows(); ++r)
-        for (unsigned int c=0; c<this->n_block_cols(); ++c)
-          this->block(r,c) = d;
-
-      return *this;
-    }
-
-
     void
     BlockSparseMatrix::
     reinit (const unsigned int n_block_rows,
index 8b683ddb7ef41c00ce42eddc122c6138270b2e5f..3083a8389c7c5e41a879c27d514adb6f3f5d1880 100644 (file)
@@ -47,18 +47,6 @@ namespace TrilinosWrappers
 
 
 
-  BlockSparseMatrix &
-  BlockSparseMatrix::operator = (const double d)
-  {
-    for (unsigned int r=0; r<this->n_block_rows(); ++r)
-      for (unsigned int c=0; c<this->n_block_cols(); ++c)
-        this->block(r,c) = d;
-
-    return *this;
-  }
-
-
-
   void
   BlockSparseMatrix::
   reinit (const unsigned int n_block_rows,

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.