]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix more places. Also fix documentation.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 18 Nov 2007 05:26:41 +0000 (05:26 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 18 Nov 2007 05:26:41 +0000 (05:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@15511 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/full_matrix.h
deal.II/lac/include/lac/full_matrix.templates.h

index 5e98e798f6128b1f84d1f08a162017313bdcb542..e147ac1cb963e396bc0f344a99d0cdefeeb9095f 100644 (file)
@@ -685,20 +685,19 @@ class FullMatrix : public Table<2,number>
                                     /**
                                      * Add rectangular block.
                                      *
-                                     * A rectangular block of the
-                                     * matrix <tt>src</tt> is added to
-                                     * <tt>this</tt>. The upper left
-                                     * corner of the block being
-                                     * copied is
+                                     * A rectangular block of the matrix
+                                     * <tt>src</tt> is added to
+                                     * <tt>this</tt>. The upper left corner
+                                     * of the block being copied is
                                      * <tt>(src_offset_i,src_offset_j)</tt>.
-                                     * The upper left corner of the
-                                     * copied block is
+                                     * 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>.
+                                     * 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>
+                                     * and the given offsets.
                                      */
     template<typename number2>
     void add (const FullMatrix<number2> &src,
index 2951ec59a7ab3cc97aed2a9e28fb481e71c14f24..1d81ad58dacf7e510f3c414f8fbaa522c48c8617 100644 (file)
@@ -455,18 +455,25 @@ void FullMatrix<number>::fill (const FullMatrix<number2> &src,
                               const unsigned int src_offset_i,
                               const unsigned int src_offset_j)
 {
+  Assert (dst_offset_i < m(),
+         ExcIndexRange (dst_offset_i, 0, m()));
+  Assert (dst_offset_j < n(),
+         ExcIndexRange (dst_offset_j, 0, n()));
+  Assert (src_offset_i < src.m(),
+         ExcIndexRange (src_offset_i, 0, src.m()));
+  Assert (src_offset_j < src.n(),
+         ExcIndexRange (src_offset_j, 0, src.n()));
+  
                                   // Compute maximal size of copied block
-  const unsigned int rows = (m() - dst_offset_i >= src.m() - src_offset_i)
-                           ? src.m() - src_offset_i
-                           : m() - dst_offset_i;
-  const unsigned int cols = (n() - dst_offset_j >= src.n() - src_offset_j)
-                           ? src.n() - src_offset_j
-                           : n() - dst_offset_j;
+  const unsigned int rows = std::min (m() - dst_offset_i,
+                                     src.m() - src_offset_i);
+  const unsigned int cols = std::min (n() - dst_offset_j,
+                                     src.n() - src_offset_j);
   
   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);
+      (*this)(dst_offset_i+i,dst_offset_j+j)
+       = src(src_offset_i+i,src_offset_j+j);
 }
 
 
@@ -1578,12 +1585,10 @@ void FullMatrix<number>::add (const FullMatrix<number2> &src,
          ExcIndexRange (src_offset_j, 0, src.n()));
   
                                   // 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();
+  const unsigned int rows = std::min (m() - dst_offset_i,
+                                     src.m() - src_offset_i);
+  const unsigned int cols = std::min (n() - dst_offset_j,
+                                     src.n() - src_offset_j);
   
   for (unsigned int i=0; i<rows ; ++i)
     for (unsigned int j=0; j<cols ; ++j)
@@ -1602,18 +1607,25 @@ void FullMatrix<number>::Tadd (const FullMatrix<number2> &src,
                              const unsigned int src_offset_i,
                              const unsigned int src_offset_j)
 {
+  Assert (dst_offset_i < m(),
+         ExcIndexRange (dst_offset_i, 0, m()));
+  Assert (dst_offset_j < n(),
+         ExcIndexRange (dst_offset_j, 0, n()));
+  Assert (src_offset_i < src.m(),
+         ExcIndexRange (src_offset_i, 0, src.m()));
+  Assert (src_offset_j < src.n(),
+         ExcIndexRange (src_offset_j, 0, src.n()));
+  
                                   // 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();
+  const unsigned int rows = std::min (m() - dst_offset_i,
+                                     src.m() - src_offset_i);
+  const unsigned int cols = std::min (n() - dst_offset_j,
+                                     src.n() - src_offset_j);
   
   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);
+      (*this)(dst_offset_i+i,dst_offset_j+j)
+       += factor * src(src_offset_i+j,src_offset_j+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.