]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
FullMatrix::mmult and Tmmult have now an additional adding argument.
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 29 Mar 2001 13:51:58 +0000 (13:51 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 29 Mar 2001 13:51:58 +0000 (13:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@4322 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/2001/c-3-1.html
deal.II/lac/include/lac/full_matrix.h
deal.II/lac/include/lac/full_matrix.templates.h
deal.II/lac/source/full_matrix.double.cc
deal.II/lac/source/full_matrix.float.cc

index 756ed96c195e871d535aae168231afe1d29edae4..41224c6513c5d238f95406fcb51ec7e479faf2f3 100644 (file)
@@ -215,7 +215,7 @@ documentation, etc</a>.
 
 
   <li> <p>
-       Change: Sort the quadrature points of each <code
+       Changed: Sort the quadrature points of each <code
        class="class">Quadrature&lt;1&gt;</code> in ascending order. This
        actually changed the order of the points of only <code
        class="class">QGauss4</code> and <code
@@ -238,13 +238,28 @@ documentation, etc</a>.
 <h3>lac</h3>
 
 <ol>
+  <li> <p> 
+       New: The functions <code class="class">FullMatrix</code>::<code
+       class="member">mmult</code> and <code
+       class="member">Tmmult</code> now have an additional
+       <code>adding</code> argument. If this flag is
+       <code>true</code>, the matrix-matrix product is added to the
+       resulting matrix; if <code>false</code>, the resulting matrix
+       is set to (overwritten by) the matrix-matrix product. The
+       latter is the behaviour these functions had before. Hence the
+       default value is set to be <code>false</code> to ensure
+       backward compatibility.
+       <br>
+       (RH 2001/03/29)
+       </p>
+
   <li> <p>
        New: class <code class="class">SchurMatrix</code> implements
        a Schur complement for block matrices. It provides matrix-vector
        multiplication suitable for iterative methods as well as pre- and
        post-processing of right hand side and slution, respectively. 
        <br>
-       (GK 2001/02/13)
+       (GK 2001/03/22)
        </p>
 
   <li> <p>
@@ -377,13 +392,14 @@ documentation, etc</a>.
   <li> <p>
        Changed: The syntax of the <code
        class="class">FiniteElement&lt;dim&gt;</code>::<code
-       class="member">get_unit_support_points</code>
-       function is changed; it returns a reference to the vector of
-       points. These points are now computed by the constructor of the
-       <code class="class">FiniteElement</code> and not on each <code
+       class="member">get_unit_support_points</code> function is
+       changed; it returns a reference to the vector of points in lieu
+       of taking this vector as argument. The unit support points are
+       now computed by the constructor of the <code
+       class="class">FiniteElement</code> and not on each <code
        class="class">FiniteElement&lt;dim&gt;</code>::<code
-       class="member">get_unit_support_points</code>
-       function call as before.
+       class="member">get_unit_support_points</code> function call as
+       before.
        <br>
        (WB 2001/03/14)
        </p>
index e3dd4db6f654190353ef20435243327adfae0077..790ca439f3ebd70c83a069eb4f0fbe76d977b2fa 100644 (file)
@@ -284,28 +284,50 @@ class FullMatrix : public Subscriptor
     
                                     /**
                                      * Matrix-matrix-multiplication.
-                                     * $C=A*B$.
+                                     *
+                                     * The optional parameter
+                                     * @p{adding} determines, whether the
+                                     * result is stored in @p{C} or added
+                                     * to @p{C}.
+                                     *
+                                     * if (adding)
+                                     *  $C += A*B$
+                                     *
+                                     * if (!adding)
+                                     *  $C = A*B$
                                      *
                                      * Assumes that @p{A} and @p{B} have
-                                     * compatible sizes and thet @p{C}
+                                     * compatible sizes and that @p{C}
                                      * already has the right size.
                                      */
     template<typename number2>
     void mmult (FullMatrix<number2>       &C,
-               const FullMatrix<number2> &B) const;
+               const FullMatrix<number2> &B,
+               const bool                 adding=false) const;
     
                                     /**
                                      * Matrix-matrix-multiplication using
                                      * transpose of @p{this}.
-                                     * $C=A^T*B$.
+                                     *
+                                     * The optional parameter
+                                     * @p{adding} determines, whether the
+                                     * result is stored in @p{C} or added
+                                     * to @p{C}.
+                                     *
+                                     * if (adding)
+                                     *  $C += A^T*B$
+                                     *
+                                     * if (!adding)
+                                     *  $C = A^T*B$
                                      *
                                      * Assumes that @p{A} and @p{B} have
-                                     * compatible sizes and thet @p{C}
+                                     * compatible sizes and that @p{C}
                                      * already has the right size.
                                      */
     template<typename number2>
     void Tmmult (FullMatrix<number2>       &C,
-                const FullMatrix<number2> &B) const;
+                const FullMatrix<number2> &B,
+                const bool                 adding=false) const;
     
                                     /**
                                      * Matrix-vector-multiplication.
index 784127b95f318e15f83e4266e6e5dc5a9dcb2b99..58cec6898498fe1d52065485997fa42ac95a7e38 100644 (file)
@@ -575,21 +575,32 @@ void FullMatrix<number>::diagadd (const number src)
 template <typename number>
 template <typename number2>
 void FullMatrix<number>::mmult (FullMatrix<number2>       &dst,
-                               const FullMatrix<number2> &src) const
+                               const FullMatrix<number2> &src,
+                               const bool                 adding) const
 {
   Assert (val != 0, ExcEmptyMatrix());
   Assert (n() == src.m(), ExcDimensionMismatch(n(), src.m()));
   Assert (dst.n() == src.n(), ExcDimensionMismatch(dst.n(), src.n()));
   Assert (dst.m() == m(), ExcDimensionMismatch(m(), dst.m()));
-  
-  for (unsigned int i=0; i<m(); i++)
-    for (unsigned int j=0; j<src.n(); j++)
-      {
-       number2 s = 0.;
-       for (unsigned k=0; k<n(); k++)
-         s+= el(i,k) * src.el(k,j);
-       dst.el(i,j) = s;
-      }
+
+  if (!adding)
+    for (unsigned int i=0; i<m(); i++)
+      for (unsigned int j=0; j<src.n(); j++)
+       {
+         number2 s = 0.;
+         for (unsigned k=0; k<n(); k++)
+           s+= el(i,k) * src.el(k,j);
+         dst.el(i,j) = s;
+       }
+  else
+    for (unsigned int i=0; i<m(); i++)
+      for (unsigned int j=0; j<src.n(); j++)
+       {
+         number2 s = 0.;
+         for (unsigned k=0; k<n(); k++)
+           s+= el(i,k) * src.el(k,j);
+         dst.el(i,j) += s;
+       }
 }
 
 
@@ -597,21 +608,32 @@ void FullMatrix<number>::mmult (FullMatrix<number2>       &dst,
 template <typename number>
 template <typename number2>
 void FullMatrix<number>::Tmmult (FullMatrix<number2>       &dst,
-                                const FullMatrix<number2> &src) const
+                                const FullMatrix<number2> &src,
+                                const bool                 adding) const
 {
   Assert (val != 0, ExcEmptyMatrix());  
   Assert (m() == src.m(), ExcDimensionMismatch(m(), src.m()));
   Assert (n() == dst.m(), ExcDimensionMismatch(n(), dst.m()));
   Assert (src.n() == dst.n(), ExcDimensionMismatch(src.n(), dst.n()));
 
-  for (unsigned int i=0; i<n(); i++)
-    for (unsigned int j=0; j<src.n(); j++)
-      {
-       number2 s = 0;
-       for (unsigned int k=0; k<m(); k++)
-         s += el(k,i) * src.el(k,j);
-       dst.el(i,j) = s;
-      }
+  if (!adding)
+    for (unsigned int i=0; i<n(); i++)
+      for (unsigned int j=0; j<src.n(); j++)
+       {
+         number2 s = 0;
+         for (unsigned int k=0; k<m(); k++)
+           s += el(k,i) * src.el(k,j);
+         dst.el(i,j) = s;
+       }
+  else
+    for (unsigned int i=0; i<n(); i++)
+      for (unsigned int j=0; j<src.n(); j++)
+       {
+         number2 s = 0;
+         for (unsigned int k=0; k<m(); k++)
+           s += el(k,i) * src.el(k,j);
+         dst.el(i,j) += s;
+       }
 }
 
 
index 8120750d4f423cba890666c9d8f5371f3f01a6d3..9af1dd9c6c08dfc85690d7d821f8832825cbff5a 100644 (file)
@@ -26,8 +26,8 @@ template void FullMatrix<TYPEMAT>::fill (const FullMatrix<TYPEMAT2>&, const unsi
 template void FullMatrix<TYPEMAT>::reinit (const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::add (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::Tadd (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
-template void FullMatrix<TYPEMAT>::mmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&) const;
-template void FullMatrix<TYPEMAT>::Tmmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&) const;
+template void FullMatrix<TYPEMAT>::mmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
+template void FullMatrix<TYPEMAT>::Tmmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
 template void FullMatrix<TYPEMAT>::add_diag (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 
 
index 9460efb4673a2f359c8b4fa37e3f7ed1b2d956be..a70961cf86952371633ae5a9ba15fdd3289cd5a2 100644 (file)
@@ -25,8 +25,8 @@ template void FullMatrix<TYPEMAT>::fill (const FullMatrix<TYPEMAT2>&, const unsi
 template void FullMatrix<TYPEMAT>::reinit (const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::add (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::Tadd (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
-template void FullMatrix<TYPEMAT>::mmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&) const;
-template void FullMatrix<TYPEMAT>::Tmmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&) const;
+template void FullMatrix<TYPEMAT>::mmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
+template void FullMatrix<TYPEMAT>::Tmmult (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
 template void FullMatrix<TYPEMAT>::add_diag (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 
 

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.