]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
added functions *= and /= for consistency with similar functions in
authorbrian <brian@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 Jun 2003 13:51:46 +0000 (13:51 +0000)
committerbrian <brian@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 Jun 2003 13:51:46 +0000 (13:51 +0000)
FullMatrix, Vector classes.

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

deal.II/lac/include/lac/sparse_matrix.h

index 2bdf3e96f150ca2190bdc896983e5fafe657b714..8cfea37b486ffcd998e75a7ccc53916cc7fa96d8 100644 (file)
@@ -371,6 +371,18 @@ class SparseMatrix : public virtual Subscriptor
     void set (const unsigned int i, const unsigned int j,
              const number value);
     
+                                    /**
+                                     * Multiply the entire matrix by a
+                                     * fixed factor.
+                                     */
+    SparseMatrix & operator *= (const number factor);
+    
+                                    /**
+                                     * Divide the entire matrix by a
+                                     * fixed factor.
+                                     */
+    SparseMatrix & operator /= (const number factor);
+    
                                     /**
                                      * Add @p{value} to the element
                                      * @p{(i,j)}.  Throws an error if
@@ -1252,6 +1264,44 @@ void SparseMatrix<number>::add (const unsigned int i,
 
 
 
+template <typename number>
+inline
+SparseMatrix<number> &
+SparseMatrix<number>::operator *= (const number factor)
+{
+  Assert (cols != 0, ExcMatrixNotInitialized());
+  Assert (val != 0, ExcMatrixNotInitialized());
+
+  number             *val_ptr    = &val[0];
+  const number *const end_ptr    = &val[cols->n_nonzero_elements()];
+
+  while (val_ptr != end_ptr)
+    *val_ptr++ *= factor;
+
+  return *this;
+}
+
+
+
+template <typename number>
+inline
+SparseMatrix<number> &
+SparseMatrix<number>::operator /= (const number factor)
+{
+  Assert (cols != 0, ExcMatrixNotInitialized());
+  Assert (val != 0, ExcMatrixNotInitialized());
+
+  number             *val_ptr    = &val[0];
+  const number *const end_ptr    = &val[cols->n_nonzero_elements()];
+
+  while (val_ptr != end_ptr)
+    *val_ptr++ /= factor;
+
+  return *this;
+}
+
+
+
 template <typename number>
 inline
 number SparseMatrix<number>::operator () (const unsigned int i,

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.