From 13aeb4f7e76362f2e55eb90da564de4b76bbb5d1 Mon Sep 17 00:00:00 2001 From: guido Date: Mon, 31 Mar 2003 12:23:08 +0000 Subject: [PATCH] fill generalized git-svn-id: https://svn.dealii.org/trunk@7343 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/2002/c-3-4.html | 8 +++++ deal.II/lac/include/lac/full_matrix.h | 36 +++++++++++-------- .../lac/include/lac/full_matrix.templates.h | 24 ++++++++----- deal.II/lac/source/full_matrix.double.cc | 3 +- deal.II/lac/source/full_matrix.float.cc | 3 +- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 18ebb7eec6..a5190e37ec 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -563,6 +563,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

lac

    +
  1. Improved: FullMatrix::fill now copies the largest possible block, + whether the destination or source matrix is bigger. Additionally, an + offset inside the source matrix may be specified. +
    + (GK 2003/03/31) +

    +
  2. New/Changed: The SparseILU, SparseMIC and /** * 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 void fill (const FullMatrix &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 double least_squares (Vector &dst, diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h index 53edc94dd9..67c6f86cef 100644 --- a/deal.II/lac/include/lac/full_matrix.templates.h +++ b/deal.II/lac/include/lac/full_matrix.templates.h @@ -386,15 +386,23 @@ void FullMatrix::backward (Vector &dst, template template void FullMatrix::fill (const FullMatrix &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; iiel(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; iel(dst_offset_i+i,dst_offset_j+j) + = src.el(src_offset_i+i,src_offset_j+j); } diff --git a/deal.II/lac/source/full_matrix.double.cc b/deal.II/lac/source/full_matrix.double.cc index 07fe098a59..e0471cb1f1 100644 --- a/deal.II/lac/source/full_matrix.double.cc +++ b/deal.II/lac/source/full_matrix.double.cc @@ -22,7 +22,8 @@ template class FullMatrix; #define TYPEMAT2 double //template FullMatrix& FullMatrix::operator =(const FullMatrix&); -template void FullMatrix::fill (const FullMatrix&, const unsigned, const unsigned); +template void FullMatrix::fill ( + const FullMatrix&, const unsigned, const unsigned, const unsigned, const unsigned); template void FullMatrix::add (const TYPEMAT, const FullMatrix&); template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); template void FullMatrix::mmult (FullMatrix&, const FullMatrix&, const bool) const; diff --git a/deal.II/lac/source/full_matrix.float.cc b/deal.II/lac/source/full_matrix.float.cc index 9980c4cef8..357a786164 100644 --- a/deal.II/lac/source/full_matrix.float.cc +++ b/deal.II/lac/source/full_matrix.float.cc @@ -21,7 +21,8 @@ template class FullMatrix; #define TYPEMAT2 float //template FullMatrix& FullMatrix::operator =<>(const FullMatrix&); -template void FullMatrix::fill (const FullMatrix&, const unsigned, const unsigned); +template void FullMatrix::fill ( + const FullMatrix&, const unsigned, const unsigned, const unsigned, const unsigned); template void FullMatrix::add (const TYPEMAT, const FullMatrix&); template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); template void FullMatrix::mmult (FullMatrix&, const FullMatrix&, const bool) const; -- 2.39.5