]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add transpose block
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 12 Feb 2004 10:16:46 +0000 (10:16 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 12 Feb 2004 10:16:46 +0000 (10:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@8461 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/c-4-0.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 bc6dc5cfdb630249b6a1596bbc87be16d41d60ea..cb18d0999858c9ac5480d0ab66f2261587c3b029 100644 (file)
@@ -276,10 +276,12 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 
 <ol>
 
-  <li> <p> New:<code class="class">FullMatrix</code> has a new function add,
+  <li> <p> New:<code class="class">FullMatrix</code> has new functions <code
+  class="member">add</code> and ,<code
+  class="member">Tadd</code>
   allowing to add to a selected block of the matrix.
   <br>
-  (GK 2004/02/09)
+  (GK 2004/02/12)
   </p>
   
   <li> <p> Improved: Initialization routines of class <code
index 416efca4d91f7b983760b2feadd26247ea2dc546..db5ce32aec1b1a3ed7a2d38c238fe8260cca667f 100644 (file)
@@ -432,6 +432,36 @@ class FullMatrix : public Table<2,number>
     void Tadd (const number               s,
               const FullMatrix<number2> &B);
     
+                                    /**
+                                     * Add transose of a rectangular block.
+                                     *
+                                     * A rectangular block of the
+                                     * matrix <tt>src</tt> is
+                                     * transposed and addedadded to
+                                     * <tt>this</tt>. The upper left
+                                     * corner of the block being
+                                     * copied is
+                                     * <tt>(src_offset_i,src_offset_j)</tt>
+                                     * in the coordinates of the
+                                     * <b>non</b>-transposed matrix.
+                                     * The upper left corner of the
+                                     * copied block is
+                                     * <tt>(dst_offset_i,dst_offset_j)</tt>.
+                                     * The size of the rectangular
+                                     * block being copied is the
+                                     * maximum size possible,
+                                     * determined either by the size
+                                     * of <tt>this</tt> or
+                                     * <tt>src</tt>.
+                                     */
+    template<typename number2>
+    void Tadd (const FullMatrix<number2> &src,
+             const double factor,
+             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);
+    
                                     /**
                                      * Matrix-matrix-multiplication.
                                      *
index 01d7ac2262d1e5b020421f7c54353cfed79cee3a..cf3854ec89a1a0a0156ec42e8e3c3e0e120a1386 100644 (file)
@@ -890,6 +890,31 @@ void FullMatrix<number>::add (const FullMatrix<number2> &src,
 
 
 
+template <typename number>
+template <typename number2>
+void FullMatrix<number>::Tadd (const FullMatrix<number2> &src,
+                             const double factor,
+                             const unsigned int dst_offset_i,
+                             const unsigned int dst_offset_j,
+                             const unsigned int src_offset_i,
+                             const unsigned int src_offset_j)
+{
+                                  // Compute maximal size of copied block
+  const unsigned int rows = (m() - dst_offset_i >= src.n() - src_offset_i)
+                           ? src.n()
+                           : m();
+  const unsigned int cols = (n() - dst_offset_j >= src.m() - src_offset_j)
+                           ? src.m()
+                           : 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)
+       += factor * src.el(src_offset_i+j,src_offset_j+i);
+}
+
+
+
 template <typename number>
 template <typename number2>
 void
index b74cc61cb243bd4b6cfe9696f124ce60143767c4..fb891a264cb21e76521a4515396b5df40f2721bf 100644 (file)
@@ -30,6 +30,8 @@ template void FullMatrix<TYPEMAT>::add<TYPEMAT2> (const TYPEMAT, const FullMatri
 template void FullMatrix<TYPEMAT>::add<TYPEMAT2> (
   const FullMatrix<TYPEMAT2>&, double, unsigned, unsigned, unsigned, unsigned);
 template void FullMatrix<TYPEMAT>::Tadd<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
+template void FullMatrix<TYPEMAT>::Tadd<TYPEMAT2> (
+  const FullMatrix<TYPEMAT2>&, double, unsigned, unsigned, unsigned, unsigned);
 template void FullMatrix<TYPEMAT>::mmult<TYPEMAT2> (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
 template void FullMatrix<TYPEMAT>::Tmmult<TYPEMAT2> (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
 template void FullMatrix<TYPEMAT>::add_diag<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
index c130f26d3b3de94be871d6789e1c7c7529b64984..5a303d3ecd3fd2f890b75da96e38431586ffc57a 100644 (file)
@@ -30,6 +30,8 @@ template void FullMatrix<TYPEMAT>::add<TYPEMAT2> (const TYPEMAT, const FullMatri
 template void FullMatrix<TYPEMAT>::add<TYPEMAT2> (
   const FullMatrix<TYPEMAT2>&, double, unsigned, unsigned, unsigned, unsigned);
 template void FullMatrix<TYPEMAT>::Tadd<TYPEMAT2> (const TYPEMAT, const FullMatrix<TYPEMAT2>&);
+template void FullMatrix<TYPEMAT>::Tadd<TYPEMAT2> (
+  const FullMatrix<TYPEMAT2>&, double, unsigned, unsigned, unsigned, unsigned);
 template void FullMatrix<TYPEMAT>::mmult<TYPEMAT2> (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
 template void FullMatrix<TYPEMAT>::Tmmult<TYPEMAT2> (FullMatrix<TYPEMAT2>&, const FullMatrix<TYPEMAT2>&, const bool) const;
 template void FullMatrix<TYPEMAT>::add_diag<TYPEMAT2> (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.