]> https://gitweb.dealii.org/ - dealii.git/commitdiff
print function
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 11 Feb 2004 12:58:31 +0000 (12:58 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 11 Feb 2004 12:58:31 +0000 (12:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@8458 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparsity_pattern.h
deal.II/lac/source/block_sparsity_pattern.cc

index a0a1be0856b1a05fe5c8e50c49eb118b0ef609e6..65dbbc9a0cf62f30d611f53a2c8cc81babb19495 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -316,6 +316,18 @@ class BlockSparsityPatternBase : public Subscriptor
                                      */
     unsigned int n_nonzero_elements () const;
 
+                                    /**
+                                     * Print the sparsity of the
+                                     * matrix. The output consists of
+                                     * one line per row of the format
+                                     * <tt>[i,j1,j2,j3,...]</tt>. <i>i</i>
+                                     * is the row number and
+                                     * <i>jn</n> are the allocated
+                                     * columns in this row.
+                                     */
+    void print (std::ostream &out) const;
+
+
                                     /**
                                      * Exception
                                      */
index 316639cbd27c4a0dca56f9643df17a1a5a0ac00a..a9035836d0cda092fcb499d882cf9a2989ac58ad 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003 by the deal authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -233,6 +233,32 @@ BlockSparsityPatternBase<SparsityPatternBase>::n_nonzero_elements () const
 
 
 
+template <class SparsityPatternBase>
+void
+BlockSparsityPatternBase<SparsityPatternBase>::print(std::ostream& out) const
+{
+  unsigned int k=0;
+  for (unsigned int ib=0;ib<n_block_rows();++ib)
+    {
+      for (unsigned int i=0;i<block(ib,ib).n_rows();++i)
+       {
+         out << '[' << i+k;
+         unsigned int l=0;
+         for (unsigned int jb=0;jb<n_block_cols();++jb)
+           {
+             const SparsityPatternBase& b = block(ib,jb);
+             for (unsigned int j=0;j<b.n_cols();++j)
+               if (b.exists(i,j))
+                 out << ',' << l+j;
+             l += b.n_cols();
+           }
+         out << ']' << std::endl;
+       }
+      k += block(ib,ib).n_rows();
+    }
+}
+
+
 BlockSparsityPattern::BlockSparsityPattern ()
 {}
 
@@ -258,7 +284,6 @@ BlockSparsityPattern::is_compressed () const
 }
 
 
-
 unsigned int
 BlockSparsityPattern::memory_consumption () 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.