From 1abd0da0c15c0bdedf512c6aa5e33181de7ff5f4 Mon Sep 17 00:00:00 2001 From: ESeNonFossiIo Date: Tue, 12 Apr 2016 22:07:38 +0200 Subject: [PATCH] add m() and n() methods --- include/deal.II/lac/petsc_sparse_matrix.h | 10 ++++++++++ source/lac/petsc_sparse_matrix.cc | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/deal.II/lac/petsc_sparse_matrix.h b/include/deal.II/lac/petsc_sparse_matrix.h index 655379cf6c..4c6dbc037c 100644 --- a/include/deal.II/lac/petsc_sparse_matrix.h +++ b/include/deal.II/lac/petsc_sparse_matrix.h @@ -225,6 +225,16 @@ namespace PETScWrappers PetscScalar matrix_scalar_product (const VectorBase &u, const VectorBase &v) const; + /** + * Return the number of rows of this matrix. + */ + size_t m() const; + + /** + * Return the number of coloumns of this matrix. + */ + size_t n() const; + private: /** diff --git a/source/lac/petsc_sparse_matrix.cc b/source/lac/petsc_sparse_matrix.cc index 22c577252f..d0b4297824 100644 --- a/source/lac/petsc_sparse_matrix.cc +++ b/source/lac/petsc_sparse_matrix.cc @@ -308,7 +308,24 @@ namespace PETScWrappers } } + size_t + SparseMatrix::m () const + { + PetscInt m,n; + PetscErrorCode ierr = MatGetSize(matrix, &m, &n); + + return m; + } + size_t + SparseMatrix::n () const + { + PetscInt m,n; + PetscErrorCode ierr = MatGetSize(matrix, &m, &n); + + return n; + } + // Explicit instantiations // template -- 2.39.5