<br>
(Timo Heister, 2015/09/05)
+ <li> New: There is now a function SparsityPattern::print_svg() which prints the sparsity of the matrix
+ in a .svg file which can be opened in a web browser.
+ <br>
+ (Conrad Clevenger, 2015/09/03)
+ </li>
+
<li> Openmp SIMD support is now enabled for Clang version 3.6, or newer
(or the equivalent XCode version). Further, openmp support is not any
more falsely activated for very old clang versions.
*/
void print_gnuplot (std::ostream &out) const;
+ /**
+ * Prints the sparsity of the matrix in a .svg file which can be opened in a web browser.
+ * The .svg file contains squares which correspond to the entries in the matrix. An entry
+ * in the matrix which contains a non-zero value corresponds with a red square while a
+ * zero-valued entry in the matrix correspond with a white square.
+ */
+ void print_svg (std::ostream &out) const;
+
+
/**
* Write the data of this object to a stream for the purpose of
* serialization
AssertThrow (out, ExcIO());
}
+void
+SparsityPattern::print_svg (std::ostream &out) const
+{
+ unsigned int m = this->n_rows();
+ unsigned int n = this->n_cols();
+ out << "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 " << n+2
+ << " " << m+2 << " \">\n"
+ "<style type=\"text/css\" >\n"
+ " <![CDATA[\n"
+ " rect.pixel {\n"
+ " fill: #ff0000;\n"
+ " }\n"
+ " ]]>\n"
+ " </style>\n\n"
+ " <rect width=\"" << n+2 << "\" height=\"" << m+2 << "\" fill=\"rgb(128, 128, 128)\"/>\n"
+ " <rect x=\"1\" y=\"1\" width=\"" << n << "\" height=\"" << m
+ << "\" fill=\"rgb(255, 255, 255)\"/>\n\n";
+
+ SparsityPattern::iterator
+ it = this->begin(),
+ end = this->end();
+ for (; it!=end; ++it)
+ {
+ out << " <rect class=\"pixel\" x=\"" << it->column()+1
+ << "\" y=\"" << it->row()+1
+ << "\" width=\".9\" height=\".9\"/>\n";
+ }
+ out << "</svg>" << std::endl;
+
+}
+
+
SparsityPattern::size_type
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparsityPattern::write_svg
+
+#include "../tests.h"
+#include <deal.II/lac/sparsity_pattern.h>
+
+int main ()
+{
+ initlog();
+
+ SparsityPattern sparsity (2,3,3);
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<3; ++j)
+ if (i<j)
+ sparsity.add (i,j);
+ sparsity.compress ();
+
+ sparsity.print_svg (deallog.get_file_stream());
+}
+
+
+
--- /dev/null
+
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 5 4 ">
+<style type="text/css" >
+ <![CDATA[
+ rect.pixel {
+ fill: #ff0000;
+ }
+ ]]>
+ </style>
+
+ <rect width="5" height="4" fill="rgb(128, 128, 128)"/>
+ <rect x="1" y="1" width="3" height="2" fill="rgb(255, 255, 255)"/>
+
+ <rect class="pixel" x="2" y="1" width=".9" height=".9"/>
+ <rect class="pixel" x="3" y="1" width=".9" height=".9"/>
+ <rect class="pixel" x="3" y="2" width=".9" height=".9"/>
+</svg>