From 038d90f57be03ee5119b1fbe125e385936ac2478 Mon Sep 17 00:00:00 2001 From: Ralf Hartmann Date: Thu, 29 Mar 2001 13:51:58 +0000 Subject: [PATCH] FullMatrix::mmult and Tmmult have now an additional adding argument. git-svn-id: https://svn.dealii.org/trunk@4322 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/2001/c-3-1.html | 32 +++++++--- deal.II/lac/include/lac/full_matrix.h | 34 +++++++++-- .../lac/include/lac/full_matrix.templates.h | 60 +++++++++++++------ deal.II/lac/source/full_matrix.double.cc | 4 +- deal.II/lac/source/full_matrix.float.cc | 4 +- 5 files changed, 97 insertions(+), 37 deletions(-) diff --git a/deal.II/doc/news/2001/c-3-1.html b/deal.II/doc/news/2001/c-3-1.html index 756ed96c19..41224c6513 100644 --- a/deal.II/doc/news/2001/c-3-1.html +++ b/deal.II/doc/news/2001/c-3-1.html @@ -215,7 +215,7 @@ documentation, etc.
  • - Change: Sort the quadrature points of each Quadrature<1> in ascending order. This actually changed the order of the points of only QGauss4 and .

    lac

      +
    1. + New: The functions FullMatrix::mmult and Tmmult now have an additional + adding argument. If this flag is + true, the matrix-matrix product is added to the + resulting matrix; if false, the resulting matrix + is set to (overwritten by) the matrix-matrix product. The + latter is the behaviour these functions had before. Hence the + default value is set to be false to ensure + backward compatibility. +
      + (RH 2001/03/29) +

      +
    2. New: class SchurMatrix implements a Schur complement for block matrices. It provides matrix-vector multiplication suitable for iterative methods as well as pre- and post-processing of right hand side and slution, respectively.
      - (GK 2001/02/13) + (GK 2001/03/22)

    3. @@ -377,13 +392,14 @@ documentation, etc.

    4. Changed: The syntax of the FiniteElement<dim>::get_unit_support_points - function is changed; it returns a reference to the vector of - points. These points are now computed by the constructor of the - FiniteElement and not on each get_unit_support_points function is + changed; it returns a reference to the vector of points in lieu + of taking this vector as argument. The unit support points are + now computed by the constructor of the FiniteElement and not on each FiniteElement<dim>::get_unit_support_points - function call as before. + class="member">get_unit_support_points function call as + before.
      (WB 2001/03/14)

      diff --git a/deal.II/lac/include/lac/full_matrix.h b/deal.II/lac/include/lac/full_matrix.h index e3dd4db6f6..790ca439f3 100644 --- a/deal.II/lac/include/lac/full_matrix.h +++ b/deal.II/lac/include/lac/full_matrix.h @@ -284,28 +284,50 @@ class FullMatrix : public Subscriptor /** * Matrix-matrix-multiplication. - * $C=A*B$. + * + * The optional parameter + * @p{adding} determines, whether the + * result is stored in @p{C} or added + * to @p{C}. + * + * if (adding) + * $C += A*B$ + * + * if (!adding) + * $C = A*B$ * * Assumes that @p{A} and @p{B} have - * compatible sizes and thet @p{C} + * compatible sizes and that @p{C} * already has the right size. */ template void mmult (FullMatrix &C, - const FullMatrix &B) const; + const FullMatrix &B, + const bool adding=false) const; /** * Matrix-matrix-multiplication using * transpose of @p{this}. - * $C=A^T*B$. + * + * The optional parameter + * @p{adding} determines, whether the + * result is stored in @p{C} or added + * to @p{C}. + * + * if (adding) + * $C += A^T*B$ + * + * if (!adding) + * $C = A^T*B$ * * Assumes that @p{A} and @p{B} have - * compatible sizes and thet @p{C} + * compatible sizes and that @p{C} * already has the right size. */ template void Tmmult (FullMatrix &C, - const FullMatrix &B) const; + const FullMatrix &B, + const bool adding=false) const; /** * Matrix-vector-multiplication. diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h index 784127b95f..58cec68984 100644 --- a/deal.II/lac/include/lac/full_matrix.templates.h +++ b/deal.II/lac/include/lac/full_matrix.templates.h @@ -575,21 +575,32 @@ void FullMatrix::diagadd (const number src) template template void FullMatrix::mmult (FullMatrix &dst, - const FullMatrix &src) const + const FullMatrix &src, + const bool adding) const { Assert (val != 0, ExcEmptyMatrix()); Assert (n() == src.m(), ExcDimensionMismatch(n(), src.m())); Assert (dst.n() == src.n(), ExcDimensionMismatch(dst.n(), src.n())); Assert (dst.m() == m(), ExcDimensionMismatch(m(), dst.m())); - - for (unsigned int i=0; i::mmult (FullMatrix &dst, template template void FullMatrix::Tmmult (FullMatrix &dst, - const FullMatrix &src) const + const FullMatrix &src, + const bool adding) const { Assert (val != 0, ExcEmptyMatrix()); Assert (m() == src.m(), ExcDimensionMismatch(m(), src.m())); Assert (n() == dst.m(), ExcDimensionMismatch(n(), dst.m())); Assert (src.n() == dst.n(), ExcDimensionMismatch(src.n(), dst.n())); - for (unsigned int i=0; i::fill (const FullMatrix&, const unsi template void FullMatrix::reinit (const FullMatrix&); template void FullMatrix::add (const TYPEMAT, const FullMatrix&); template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); -template void FullMatrix::mmult (FullMatrix&, const FullMatrix&) const; -template void FullMatrix::Tmmult (FullMatrix&, const FullMatrix&) const; +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 9460efb467..a70961cf86 100644 --- a/deal.II/lac/source/full_matrix.float.cc +++ b/deal.II/lac/source/full_matrix.float.cc @@ -25,8 +25,8 @@ template void FullMatrix::fill (const FullMatrix&, const unsi template void FullMatrix::reinit (const FullMatrix&); template void FullMatrix::add (const TYPEMAT, const FullMatrix&); template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); -template void FullMatrix::mmult (FullMatrix&, const FullMatrix&) const; -template void FullMatrix::Tmmult (FullMatrix&, const FullMatrix&) const; +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&); -- 2.39.5