]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
added *= and /= functions for consistency. Also added print_formatted function
authorbrian <brian@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 Jun 2003 13:53:46 +0000 (13:53 +0000)
committerbrian <brian@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 Jun 2003 13:53:46 +0000 (13:53 +0000)
similar to the one in BlockVector.

git-svn-id: https://svn.dealii.org/trunk@7718 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparse_matrix.h

index 3aa562bcdf29eeb9d376ecab729fc67251fac8d4..43344c46a05ad158eb92f4dc9139d91befc421ea 100644 (file)
@@ -410,6 +410,18 @@ class BlockSparseMatrix : public Subscriptor
              const unsigned int j,
              const number value);
     
+                                    /**
+                                     * Multiply the entire matrix by a
+                                     * fixed factor.
+                                     */
+    BlockSparseMatrix & operator *= (const number factor);
+    
+                                    /**
+                                     * Divide the entire matrix by a
+                                     * fixed factor.
+                                     */
+    BlockSparseMatrix & operator /= (const number factor);
+    
                                     /**
                                      * Add @p{value} to the element
                                      * @p{(i,j)}.  Throws an error if
@@ -619,6 +631,16 @@ class BlockSparseMatrix : public Subscriptor
                              const BlockVector<somenumber> &src,
                              const number                   omega = 1.) const;
 
+                                     /* call print functions for 
+                                     * the SparseMatrix blocks.
+                                     */
+    void print_formatted (std::ostream       &out,
+                         const unsigned int  precision   = 3,
+                         const bool          scientific  = true,
+                         const unsigned int  width       = 0,
+                         const char         *zero_string = " ",
+                         const double        denominator = 1.) const;
+
                                     /**
                                      * Return a (constant) reference
                                      * to the underlying sparsity
@@ -667,6 +689,10 @@ class BlockSparseMatrix : public Subscriptor
                                      * Exception
                                      */
     DeclException0 (ExcMatrixNotBlockSquare);
+                                    /**
+                                     * Exception
+                                     */
+    DeclException0 (ExcMatrixNotInitialized);
 
     
   private:
@@ -1023,6 +1049,40 @@ BlockSparseMatrix<number>::set (const unsigned int i,
 
 
 
+template <typename number>
+inline
+BlockSparseMatrix<number> &
+BlockSparseMatrix<number>::operator *= (const number factor)
+{
+  Assert (columns != 0, ExcMatrixNotInitialized());
+  Assert (rows != 0, ExcMatrixNotInitialized());
+
+  for (unsigned int r=0; r<rows; ++r)
+    for (unsigned int c=0; c<columns; ++c)
+      block(r,c) *= factor;
+
+  return *this;
+}
+
+
+
+template <typename number>
+inline
+BlockSparseMatrix<number> &
+BlockSparseMatrix<number>::operator /= (const number factor)
+{
+  Assert (columns != 0, ExcMatrixNotInitialized());
+  Assert (rows != 0, ExcMatrixNotInitialized());
+
+  for (unsigned int r=0; r<rows; ++r)
+    for (unsigned int c=0; c<columns; ++c)
+      block(r,c) /= factor;
+
+  return *this;
+}
+
+
+
 template <typename number>
 inline
 void

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.