From 5c5ee0cba48fd504f256ba500c29439625b6f1a2 Mon Sep 17 00:00:00 2001 From: kanschat Date: Fri, 19 Oct 2007 02:24:40 +0000 Subject: [PATCH] add SparseMatrix::print_pattern git-svn-id: https://svn.dealii.org/trunk@15349 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_matrix.h | 12 ++++++++++ .../lac/include/lac/sparse_matrix.templates.h | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index a01df8fda3..35d58d141f 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -1575,6 +1575,18 @@ class SparseMatrix : public virtual Subscriptor const char *zero_string = " ", const double denominator = 1.) const; + /** + * Print the actual pattern of + * the matrix. For each entry + * with an absolute value larger + * than threshold, a '*' is + * printed, a ':' for every value + * smaller and a '.' for every + * entry not allocated. + */ + void print_pattern(std::ostream& out, + const double threshold = 0.) const; + /** * Write the data of this object * en bloc to a file. This is diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index 8ba5136940..7361a2e1cd 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -1371,6 +1371,30 @@ void SparseMatrix::print_formatted (std::ostream &out, +template +void SparseMatrix::print_pattern (std::ostream &out, + const double threshold) const +{ + Assert (cols != 0, ExcNotInitialized()); + Assert (val != 0, ExcNotInitialized()); + + for (unsigned int i=0; ioperator()(i,j)]) > threshold) + out << '*'; + else + out << ':'; + out << std::endl; + }; + AssertThrow (out, ExcIO()); +} + + + template void SparseMatrix::block_write (std::ostream &out) const -- 2.39.5