From: bangerth Date: Fri, 6 Mar 2009 22:35:50 +0000 (+0000) Subject: Fix a bug in the swap_row/swap_col functions of FullMatrix. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f4b212c3f659254b56623fc23c4d30364602841;p=dealii-svn.git Fix a bug in the swap_row/swap_col functions of FullMatrix. git-svn-id: https://svn.dealii.org/trunk@18463 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 68d1a323f2..575266f5b5 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -552,6 +552,15 @@ inconvenience this causes.

lac

    +
  1. +

    + Fixed: The FullMatrix::swap_row and FullMatrix::swap_col functions + had bugs that made them only work in case the matrix was square. + This is now fixed. +
    + (WB 2009/03/05) +

    +
  2. New: Added a few simple helper functions (to VectorBase) that allow diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h index f762319086..9598f0fbaf 100644 --- a/deal.II/lac/include/lac/full_matrix.templates.h +++ b/deal.II/lac/include/lac/full_matrix.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -446,28 +446,26 @@ void FullMatrix::add_col (const unsigned int i, const number s, template -void FullMatrix::swap_row (const unsigned int i, const unsigned int j) +void FullMatrix::swap_row (const unsigned int i, + const unsigned int j) { Assert (!this->empty(), ExcEmptyMatrix()); - number s; - for (unsigned int k=0; k -void FullMatrix::swap_col (const unsigned int i, const unsigned int j) +void FullMatrix::swap_col (const unsigned int i, + const unsigned int j) { Assert (!this->empty(), ExcEmptyMatrix()); - number s; - for (unsigned int k=0; k +void +check () +{ + FullMatrix m (5, 7); + fill_matrix (m); + print_matrix (m); + + m.swap_col (2, 4); + print_matrix (m); + + m.swap_row (2, 4); + print_matrix (m); +} + diff --git a/tests/bits/full_matrix_55/cmp/generic b/tests/bits/full_matrix_55/cmp/generic new file mode 100644 index 0000000000..0253c8d3ce --- /dev/null +++ b/tests/bits/full_matrix_55/cmp/generic @@ -0,0 +1,51 @@ + +DEAL::0 0 2.0 +DEAL::0 1 3.0 +DEAL::0 2 6.0 +DEAL::0 3 5.0 +DEAL::0 4 4.0 +DEAL::1 0 4.0 +DEAL::1 1 6.0 +DEAL::1 2 12. +DEAL::1 3 10. +DEAL::1 4 8.0 +DEAL::2 0 6.0 +DEAL::2 1 9.0 +DEAL::2 2 18. +DEAL::2 3 15. +DEAL::2 4 12. +DEAL::3 0 8.0 +DEAL::3 1 12. +DEAL::3 2 24. +DEAL::3 3 20. +DEAL::3 4 16. +DEAL::4 0 10. +DEAL::4 1 15. +DEAL::4 2 30. +DEAL::4 3 25. +DEAL::4 4 20. +DEAL::0 0 2.0 +DEAL::0 1 3.0 +DEAL::0 2 6.0 +DEAL::0 3 5.0 +DEAL::0 4 4.0 +DEAL::1 0 4.0 +DEAL::1 1 6.0 +DEAL::1 2 12. +DEAL::1 3 10. +DEAL::1 4 8.0 +DEAL::2 0 6.0 +DEAL::2 1 9.0 +DEAL::2 2 18. +DEAL::2 3 15. +DEAL::2 4 12. +DEAL::3 0 8.0 +DEAL::3 1 12. +DEAL::3 2 24. +DEAL::3 3 20. +DEAL::3 4 16. +DEAL::4 0 10. +DEAL::4 1 15. +DEAL::4 2 30. +DEAL::4 3 25. +DEAL::4 4 20.