From: guido Date: Thu, 12 Feb 2004 10:16:46 +0000 (+0000) Subject: add transpose block X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5962f2f46b86fdf7c9e98229ca406dba94436dc2;p=dealii-svn.git add transpose block git-svn-id: https://svn.dealii.org/trunk@8461 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/c-4-0.html b/deal.II/doc/news/c-4-0.html index bc6dc5cfdb..cb18d09998 100644 --- a/deal.II/doc/news/c-4-0.html +++ b/deal.II/doc/news/c-4-0.html @@ -276,10 +276,12 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
    -
  1. New:FullMatrix has a new function add, +

  2. New:FullMatrix has new functions add and ,Tadd allowing to add to a selected block of the matrix.
    - (GK 2004/02/09) + (GK 2004/02/12)

  3. Improved: Initialization routines of class void Tadd (const number s, const FullMatrix &B); + /** + * Add transose of a rectangular block. + * + * A rectangular block of the + * matrix src is + * transposed and addedadded to + * this. The upper left + * corner of the block being + * copied is + * (src_offset_i,src_offset_j) + * in the coordinates of the + * non-transposed matrix. + * 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. + */ + template + void Tadd (const FullMatrix &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. * diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h index 01d7ac2262..cf3854ec89 100644 --- a/deal.II/lac/include/lac/full_matrix.templates.h +++ b/deal.II/lac/include/lac/full_matrix.templates.h @@ -890,6 +890,31 @@ void FullMatrix::add (const FullMatrix &src, +template +template +void FullMatrix::Tadd (const FullMatrix &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; iel(dst_offset_i+i,dst_offset_j+j) + += factor * src.el(src_offset_i+j,src_offset_j+i); +} + + + template template void diff --git a/deal.II/lac/source/full_matrix.double.cc b/deal.II/lac/source/full_matrix.double.cc index b74cc61cb2..fb891a264c 100644 --- a/deal.II/lac/source/full_matrix.double.cc +++ b/deal.II/lac/source/full_matrix.double.cc @@ -30,6 +30,8 @@ template void FullMatrix::add (const TYPEMAT, const FullMatri template void FullMatrix::add ( const FullMatrix&, double, unsigned, unsigned, unsigned, unsigned); template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); +template void FullMatrix::Tadd ( + const FullMatrix&, double, unsigned, unsigned, unsigned, unsigned); template void FullMatrix::mmult (FullMatrix&, const FullMatrix&, const bool) const; template void FullMatrix::Tmmult (FullMatrix&, const FullMatrix&, const bool) const; template void FullMatrix::add_diag (const TYPEMAT, const FullMatrix&); diff --git a/deal.II/lac/source/full_matrix.float.cc b/deal.II/lac/source/full_matrix.float.cc index c130f26d3b..5a303d3ecd 100644 --- a/deal.II/lac/source/full_matrix.float.cc +++ b/deal.II/lac/source/full_matrix.float.cc @@ -30,6 +30,8 @@ template void FullMatrix::add (const TYPEMAT, const FullMatri template void FullMatrix::add ( const FullMatrix&, double, unsigned, unsigned, unsigned, unsigned); template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); +template void FullMatrix::Tadd ( + const FullMatrix&, double, unsigned, unsigned, unsigned, unsigned); template void FullMatrix::mmult (FullMatrix&, const FullMatrix&, const bool) const; template void FullMatrix::Tmmult (FullMatrix&, const FullMatrix&, const bool) const; template void FullMatrix::add_diag (const TYPEMAT, const FullMatrix&);