From 17678efe1470e36e4811aa41d7b29cc5647915f2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 18 Nov 2007 05:26:41 +0000 Subject: [PATCH] Fix more places. Also fix documentation. git-svn-id: https://svn.dealii.org/trunk@15511 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/full_matrix.h | 23 ++++---- .../lac/include/lac/full_matrix.templates.h | 56 +++++++++++-------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/deal.II/lac/include/lac/full_matrix.h b/deal.II/lac/include/lac/full_matrix.h index 5e98e798f6..e147ac1cb9 100644 --- a/deal.II/lac/include/lac/full_matrix.h +++ b/deal.II/lac/include/lac/full_matrix.h @@ -685,20 +685,19 @@ class FullMatrix : public Table<2,number> /** * Add rectangular block. * - * A rectangular block of the - * matrix src is added to - * this. The upper left - * corner of the block being - * copied is + * A rectangular block of the matrix + * src is added to + * this. The upper left corner + * of the block being copied is * (src_offset_i,src_offset_j). - * The upper left corner of the - * copied block is + * The upper left corner of the copied + * block is * (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 this or src. + * The size of the rectangular block + * being copied is the maximum size + * possible, determined either by the + * size of this or src + * and the given offsets. */ template void add (const FullMatrix &src, diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h index 2951ec59a7..1d81ad58da 100644 --- a/deal.II/lac/include/lac/full_matrix.templates.h +++ b/deal.II/lac/include/lac/full_matrix.templates.h @@ -455,18 +455,25 @@ void FullMatrix::fill (const FullMatrix &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; iel(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::add (const FullMatrix &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::Tadd (const FullMatrix &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; iel(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); } -- 2.39.5