From: guido Date: Tue, 30 Oct 2001 13:31:24 +0000 (+0000) Subject: first version of LaTeX output X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=076307509778594160cb9a89c90c23ad4bea62c1;p=dealii-svn.git first version of LaTeX output git-svn-id: https://svn.dealii.org/trunk@5175 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/block_matrix_array.h b/deal.II/lac/include/lac/block_matrix_array.h index cde75f9ffb..a3e0595649 100644 --- a/deal.II/lac/include/lac/block_matrix_array.h +++ b/deal.II/lac/include/lac/block_matrix_array.h @@ -16,7 +16,20 @@ #include #include #include +#include + #include +#include +#include + +#ifdef HAVE_STD_STRINGSTREAM +# include +# define STRINGSTREAM std::ostringstream +#else +# include +# define STRINGSTREAM std::ostrstream +#endif + template class BlockVector; @@ -106,7 +119,13 @@ class BlockMatrixArray : public Subscriptor template void Tvmult_add (BlockVector& dst, const BlockVector& src) const; - + + /** + * Print the block structure as a + * LaTeX-array. + */ + void print_latex (ostream& out) const; + private: /** * Internal data structure. @@ -349,5 +368,50 @@ BlockMatrixArray::n_block_cols () const +template +inline +void +BlockMatrixArray::print_latex (ostream& out) const +{ + out << "\\begin{array}{" + << string(n_block_cols(), 'c') + << "}" << endl; + + vector2d array(n_block_rows(), n_block_cols()); + typedef map NameMap; + NameMap matrix_names; + + typename vector::const_iterator m = entries.begin(); + typename vector::const_iterator end = entries.end(); + + unsigned int matrix_number = 0; + for (; m != end ; ++m) + { + if (matrix_names.find(m->matrix) == matrix_names.end()) + { + pair x = + matrix_names.insert( + pair (m->matrix, string("M"))); + STRINGSTREAM stream; + stream << matrix_number++; + x.first->second += stream.str(); + } + + STRINGSTREAM stream; + if (m->prefix != 1.) + stream << " " << m->prefix << 'x'; + stream << matrix_names.find(m->matrix)->second; + if (m->transpose) + stream << "^T"; + array(m->row, m->col) += stream.str(); + } + for (unsigned int i=0;i