]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add SparseMatrix::print_pattern
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 19 Oct 2007 02:24:40 +0000 (02:24 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 19 Oct 2007 02:24:40 +0000 (02:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@15349 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_matrix.h
deal.II/lac/include/lac/sparse_matrix.templates.h

index a01df8fda3091d99bcd254023c36cc956954baab..35d58d141ff0a60158655d3233f113ff9372cf65 100644 (file)
@@ -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
index 8ba5136940525bf704267a4cb2db1bad8e620860..7361a2e1cd7920e22c277596bc933c8b0fdf68ab 100644 (file)
@@ -1371,6 +1371,30 @@ void SparseMatrix<number>::print_formatted (std::ostream &out,
 
 
 
+template <typename number>
+void SparseMatrix<number>::print_pattern (std::ostream &out,
+                                         const double threshold) const
+{
+  Assert (cols != 0, ExcNotInitialized());
+  Assert (val != 0, ExcNotInitialized());
+
+  for (unsigned int i=0; i<m(); ++i)
+    {
+      for (unsigned int j=0; j<n(); ++j)
+       if ((*cols)(i,j) == SparsityPattern::invalid_entry)
+         out << '.';
+       else
+         if (std::fabs(val[cols->operator()(i,j)]) > threshold)
+           out << '*';
+         else
+           out << ':';
+      out << std::endl;
+    };
+  AssertThrow (out, ExcIO());
+}
+
+
+
 template <typename number>
 void
 SparseMatrix<number>::block_write (std::ostream &out) const 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.