]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement CompressedSparsityPattern::print.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 31 Jul 2008 17:29:18 +0000 (17:29 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 31 Jul 2008 17:29:18 +0000 (17:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@16466 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/lac/include/lac/compressed_sparsity_pattern.h
deal.II/lac/source/compressed_sparsity_pattern.cc

index 20065bbda1fc7e2e6f676e1658ea0e7a6e308a80..a66dfc5a5b184b44ea93f313b965f592050515b0 100644 (file)
@@ -199,12 +199,21 @@ inconvenience this causes.
 <h3>lac</h3>
 
 <ol>
+  <li>
+  <p>
+  Fixed: There is now a function CompressedSparsityPattern::print, in analogy
+  to SparsityPattern::print
+  <br>
+  (WB 2008/07/31)
+  <li>
+
   <li>
   <p>
   Fixed: The FullMatrix::copy_from(FullMatrix,bool) function had a bug
   that resulted in an exception being triggered whenever the given matrix
   had rows where the diagonal element is zero and the second parameter
   to the function was set to <code>true</code>. This is now fixed.
+  <br>
   (WB 2008/07/30)
   <li>
 </ol>
index 0a4e6dba2cffe751eea8facfb6e05271debdd7e9..92e4e91ea74bb901d012dca2fc3b1b9a87eaf5fd 100644 (file)
@@ -211,6 +211,17 @@ class CompressedSparsityPattern : public Subscriptor
                                      */
     void symmetrize ();
     
+                                    /**
+                                     * 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</i> are the allocated
+                                     * columns in this row.
+                                     */
+    void print (std::ostream &out) const;
+
                                     /**
                                      * Print the sparsity of the matrix in a
                                      * format that @p gnuplot understands and
index 34a78c3e195e3d0223d025661c05f3144905db50..bf48e0818a74a87da6723d9ae03cc3b1d64de0d2 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -329,6 +329,29 @@ CompressedSparsityPattern::symmetrize ()
 
 
 
+void
+CompressedSparsityPattern::print (std::ostream &out) const
+{ 
+  for (unsigned int row=0; row<rows; ++row)
+    {
+      if (lines[row].cache_entries != 0)
+       lines[row].flush_cache ();
+
+      out << row << ' ';
+      
+      for (std::vector<unsigned int>::const_iterator
+             j=lines[row].entries.begin();
+           j != lines[row].entries.end(); ++j)
+        out << *j << ' ';
+
+      out << std::endl;
+    }
+
+  AssertThrow (out, ExcIO());
+}
+
+
+
 void
 CompressedSparsityPattern::print_gnuplot (std::ostream &out) const
 { 
@@ -345,8 +368,7 @@ CompressedSparsityPattern::print_gnuplot (std::ostream &out) const
                                          // x-y, that is we have to exchange
                                          // the order of output
         out << *j << " " << -static_cast<signed int>(row) << std::endl;
-    }
-      
+    }      
 
   AssertThrow (out, ExcIO());
 }

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.