]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fill generalized
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 31 Mar 2003 12:23:08 +0000 (12:23 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 31 Mar 2003 12:23:08 +0000 (12:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@7343 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/2002/c-3-4.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 18ebb7eec68e502e98f22ec55347760816f1e512..a5190e37ece3c21349927a9919a3d2309a04c372 100644 (file)
@@ -563,6 +563,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>lac</h3>
 
 <ol>
+  <li> <p> Improved: <code class="class">FullMatrix</code>::<code
+  class="member">fill</code> now copies the largest possible block,
+  whether the destination or source matrix is bigger. Additionally, an
+  offset inside the source matrix may be specified.
+  <br>
+  (GK 2003/03/31)
+  </p>
+
   <li> <p>
        New/Changed: The <code class="class">SparseILU</code>, <code
        class="class">SparseMIC</code> and <code
index fab9ddc6e75500dc10ac24e4da87be6eb390d747..72846570b524f2e5e439def21a551a959bf48400 100644 (file)
@@ -154,23 +154,27 @@ class FullMatrix : public Table<2,number>
                                     /**
                                      * Fill rectangular block.
                                      *
-                                     * The matrix @p{src} is copied
-                                     * into the target. The optional
-                                     * values @p{i} and @p{j}
-                                     * determine the upper left
-                                     * corner of the image of
-                                     * @p{src}.
-                                     *
-                                     * This function requires that
-                                     * @p{i+src.m()<=m()} and
-                                     * @p{j+src.n()<=n()}, that is,
-                                     * the image fits into the space
-                                     * of @p{this}.
+                                     * A rectangular block of the
+                                     * matrix @p{src} is copied into
+                                     * @p{this}. The upper left
+                                     * corner of the block being
+                                     * copied is
+                                     * @p{(src_offset_i,src_offset_j)}.
+                                     * The upper left corner of the
+                                     * copied block is
+                                     * @p{(dst_offset_i,dst_offset_j)}.
+                                     * The size of the rectangular
+                                     * block being copied is the
+                                     * maximum size possible,
+                                     * determined either by the size
+                                     * of @p{this} or @p{src}.
                                      */
     template<typename number2>
     void fill (const FullMatrix<number2> &src,
-              const unsigned int         i=0,
-              const unsigned int         j=0);
+              const unsigned int dst_offset_i = 0,
+              const unsigned int dst_offset_j = 0,
+              const unsigned int src_offset_i = 0,
+              const unsigned int src_offset_j = 0);
     
 
                                     /**
@@ -628,7 +632,9 @@ class FullMatrix : public Table<2,number>
 
                                     /**
                                      * Least-Squares-Approximation by
-                                     * QR-factorization.
+                                     * QR-factorization. The return
+                                     * value is the Euclidean norm of
+                                     * the approximation error.
                                      */
     template<typename number2>
     double least_squares (Vector<number2> &dst,
index 53edc94dd9df1f0957e6db4ec453cd9905152f5d..67c6f86cef44cb69b522521e7e5e0d9a5f3b7c9f 100644 (file)
@@ -386,15 +386,23 @@ void FullMatrix<number>::backward (Vector<number2>       &dst,
 template <typename number>
 template <typename number2>
 void FullMatrix<number>::fill (const FullMatrix<number2> &src,
-                              const unsigned int         i,
-                              const unsigned int         j)
+                              const unsigned int dst_offset_i,
+                              const unsigned int dst_offset_j,
+                              const unsigned int src_offset_i,
+                              const unsigned int src_offset_j)
 {
-  Assert (n() >= src.n() + j, ExcInvalidDestination(n(), src.n(), j));
-  Assert (m() >= src.m() + i, ExcInvalidDestination(m(), src.m(), i));
-
-  for (unsigned int ii=0; ii<src.m() ; ++ii)
-    for (unsigned int jj=0; jj<src.n() ; ++jj)
-      this->el(ii+i,jj+j) = src.el(ii,jj);
+                                  // Compute maximal size of copied block
+  const unsigned int rows = (m() - dst_offset_i >= src.m() - src_offset_i)
+                           ? src.m()
+                           : m();
+  const unsigned int cols = (n() - dst_offset_j >= src.n() - src_offset_j)
+                           ? src.n()
+                           : n();
+  
+  for (unsigned int i=0; i<rows ; ++i)
+    for (unsigned int j=0; j<cols ; ++j)
+      this->el(dst_offset_i+i,dst_offset_j+j)
+       = src.el(src_offset_i+i,src_offset_j+j);
 }
 
 
index 07fe098a59ec988a7dfab817e60f6fe9a4ac6f6c..e0471cb1f1b22e473af7406583e28d073bd9eb5b 100644 (file)
@@ -22,7 +22,8 @@ template class FullMatrix<TYPEMAT>;
 #define TYPEMAT2 double
 
 //template FullMatrix<TYPEMAT>& FullMatrix<TYPEMAT>::operator =(const FullMatrix<TYPEMAT2>&);
-template void FullMatrix<TYPEMAT>::fill<TYPEMAT2> (const FullMatrix<TYPEMAT2>&, const unsigned, const unsigned);
+template void FullMatrix<TYPEMAT>::fill<TYPEMAT2> (
+  const FullMatrix<TYPEMAT2>&, const unsigned, const unsigned, const unsigned, const unsigned);
 template void FullMatrix<TYPEMAT>::add<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::Tadd<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::mmult<TYPEMAT2> (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
index 9980c4cef89c16d25e5eb31055d2e928390faa7d..357a78616448c42aefa942329e5757c6e59f6224 100644 (file)
@@ -21,7 +21,8 @@ template class FullMatrix<TYPEMAT>;
 #define TYPEMAT2 float
 
 //template FullMatrix<TYPEMAT>& FullMatrix<TYPEMAT>::operator =<>(const FullMatrix<TYPEMAT2>&);
-template void FullMatrix<TYPEMAT>::fill<TYPEMAT2> (const FullMatrix<TYPEMAT2>&, const unsigned, const unsigned);
+template void FullMatrix<TYPEMAT>::fill<TYPEMAT2> (
+  const FullMatrix<TYPEMAT2>&, const unsigned, const unsigned, const unsigned, const unsigned);
 template void FullMatrix<TYPEMAT>::add<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::Tadd<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
 template void FullMatrix<TYPEMAT>::mmult<TYPEMAT2> (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;

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.