// $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
template <typename number>
-void FullMatrix<number>::swap_row (const unsigned int i, const unsigned int j)
+void FullMatrix<number>::swap_row (const unsigned int i,
+ const unsigned int j)
{
Assert (!this->empty(), ExcEmptyMatrix());
- number s;
- for (unsigned int k=0; k<m(); ++k)
- {
- s = (*this)(i,k); (*this)(i,k) = (*this)(j,k); (*this)(j,k) = s;
- }
+ for (unsigned int k=0; k<n(); ++k)
+ std::swap ((*this)(i,k),
+ (*this)(j,k));
}
template <typename number>
-void FullMatrix<number>::swap_col (const unsigned int i, const unsigned int j)
+void FullMatrix<number>::swap_col (const unsigned int i,
+ const unsigned int j)
{
Assert (!this->empty(), ExcEmptyMatrix());
- number s;
- for (unsigned int k=0; k<n(); ++k)
- {
- s = (*this)(k,i); (*this)(k,i) = (*this)(k,j); (*this)(k,j) = s;
- }
+ for (unsigned int k=0; k<m(); ++k)
+ std::swap ((*this)(k,i),
+ (*this)(k,j));
}
--- /dev/null
+//----------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2007, 2009 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//----------------------------------------------------------------------
+
+
+// check FullMatrix::swap_col and FullMatrix::swap_row for nonsymmetric
+// matrices; there used to be a bug in the implementation
+
+
+#include "../tests.h"
+#include "full_matrix_common.h"
+
+
+std::string output_file_name = "full_matrix_55/output";
+
+
+template <typename number>
+void
+check ()
+{
+ FullMatrix<number> 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);
+}
+