--- /dev/null
+New: LAPACKFullMatrix::remove_row_and_column() to remove certain row and column
+of the matrix.
+<br>
+(Denis Davydov, 2017/12/20)
*/
void grow_or_shrink (const size_type size);
+ /**
+ * Remove row @p row and column @p col from the matrix.
+ * \f[
+ * \left(
+ * \begin{array}{ccc}
+ * \mathbf A_{11} & \mathbf a_{12} & \mathbf A_{13} \\
+ * \mathbf a_{21}^T & a_{22} & \mathbf a_{23}^T \\
+ * \mathbf A_{31} & \mathbf a_{32} & \mathbf A_{33}
+ * \end{array}
+ * \right)
+ * \rightarrow
+ * \left(
+ * \begin{array}{cc}
+ * \mathbf A_{11} & \mathbf A_{13} \\
+ * \mathbf A_{31} & \mathbf A_{33}
+ * \end{array}
+ * \right)
+ * \f]
+ */
+ void remove_row_and_column (const size_type row, const size_type col);
+
/**
* Regenerate the current matrix by one that has the same properties as if
* it were created by the constructor of this class with the same argument
void
LAPACKFullMatrix<number>::grow_or_shrink (const size_type n)
{
- TransposeTable<number> copy(*this);
const size_type s = std::min(std::min(this->m(), n), this->n());
+ TransposeTable<number> copy(std::move(*this));
this->TransposeTable<number>::reinit (n, n);
- for (unsigned int i = 0; i < s; ++i)
- for (unsigned int j = 0; j < s; ++j)
+ for (size_type i = 0; i < s; ++i)
+ for (size_type j = 0; j < s; ++j)
(*this)(i,j) = copy(i,j);
}
+template <typename number>
+void
+LAPACKFullMatrix<number>::remove_row_and_column (const size_type row, const size_type col)
+{
+ Assert (row<this->n_rows(), ExcIndexRange(row,0,this->n_rows()));
+ Assert (col<this->n_cols(), ExcIndexRange(col,0,this->n_cols()));
+
+ const size_type nrows = this->n_rows()-1;
+ const size_type ncols = this->n_cols()-1;
+
+ TransposeTable<number> copy(std::move(*this));
+ this->TransposeTable<number>::reinit (nrows, ncols);
+
+ for (size_type j = 0; j < ncols; ++j)
+ {
+ const size_type jj = ( j < col ? j : j+1);
+ for (size_type i = 0; i < nrows; ++i)
+ {
+ const size_type ii = ( i < row ? i : i+1);
+ (*this)(i,j) = copy(ii,jj);
+ }
+ }
+}
+
+
+
template <typename number>
void
LAPACKFullMatrix<number>::reinit (const size_type m,
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test LAPACKFullMatrix removing row and column from a matrix
+
+#include "../tests.h"
+#include <deal.II/lac/lapack_full_matrix.h>
+
+#include <iostream>
+
+
+template <typename NumberType>
+void
+test()
+{
+ const unsigned int n_rows = 6;
+ const unsigned int n_cols = 9;
+ LAPACKFullMatrix<NumberType> A(n_rows,n_cols);
+
+ for (unsigned int i = 0; i < n_rows; ++i)
+ for (unsigned int j = 0; j < n_cols; ++j)
+ A(i,j) = 10*(i+1)+(j+1);
+
+ A.remove_row_and_column(2,7); // <-- 3x and x8 are removed
+ A.print_formatted(deallog.get_file_stream(), 0, false, 2);
+}
+
+
+int main()
+{
+ const std::string logname = "output";
+ std::ofstream logfile(logname.c_str());
+ logfile.precision(5);
+ deallog.attach(logfile);
+
+ test<double>();
+}
--- /dev/null
+
+11. 12. 13. 14. 15. 16. 17. 19.
+21. 22. 23. 24. 25. 26. 27. 29.
+41. 42. 43. 44. 45. 46. 47. 49.
+51. 52. 53. 54. 55. 56. 57. 59.
+61. 62. 63. 64. 65. 66. 67. 69.