16#include <dune/common/fvector.hh>
17#include <dune/common/fmatrix.hh>
18#include <dune/common/dynmatrix.hh>
19#include <dune/common/diagonalmatrix.hh>
20#include <dune/common/unused.hh>
57 for (
typename V::ConstIterator i=v.begin(); i!=v.end(); ++i)
68 template<
class K,
int n>
75 for (
int i=0; i<n; i++)
110 std::ios_base::fmtflags
oldflags =
s.flags();
113 s.setf(std::ios_base::scientific, std::ios_base::floatfield);
118 s <<
title <<
" [blocks=" << v.N() <<
",dimension=" << v.dim() <<
"]"
149 for (
int j=0; j<m; j++)
165 void print_row (std::ostream&
s,
const M& A,
typename M::size_type
I,
166 typename M::size_type
J,
typename M::size_type
therow,
169 typename M::size_type
i0=
I;
170 for (
typename M::size_type i=0; i<A.
N(); i++)
175 typename M::size_type
j0=
J;
176 for (
typename M::size_type j=0; j<A.
M(); j++)
179 typename M::ConstColIterator
it = A[i].find(j);
203 template<
class K,
int n,
int m>
215 for (size_type i=0; i<n; i++)
217 for (
int j=0; j<m; j++)
264 std::ios_base::fmtflags
oldflags =
s.flags();
267 s.setf(std::ios_base::scientific, std::ios_base::floatfield);
316 template<
class B,
int n,
int m,
class A>
324 std::ios_base::fmtflags
oldflags =
s.flags();
326 s.setf(std::ios_base::scientific, std::ios_base::floatfield);
347 Col
col=row->begin();
348 for(;
col != row->end(); ++
col,++count) {
358 s << row.index()<<
": ";
361 s<<
col.index()<<
": |";
364 for(
typename std::string::size_type i=0; i <
rowtext.length(); i++)
396 struct MatlabPODWriter
398 static std::ostream& write(
const T& t, std::ostream& s)
405 struct MatlabPODWriter<std::complex<T> >
407 static std::ostream& write(
const std::complex<T>& t, std::ostream& s)
409 s << t.real() <<
" " << t.imag();
424 template <
class FieldType,
int dim>
427 for (
int i=0; i<dim; i++)
431 MatlabPODWriter<FieldType>::write(matrix.scalar(),
s)<< std::endl;
444 template <
class FieldType,
int dim>
447 for (
int i=0; i<dim; i++)
451 MatlabPODWriter<FieldType>::write(matrix.diagonal(i),
s)<< std::endl;
464 template <
class FieldType,
int rows,
int cols>
469 for (
int i=0; i<rows; i++)
470 for (
int j=0; j<cols; j++) {
473 MatlabPODWriter<FieldType>::write(matrix[i][j],
s)<< std::endl;
486 template <
class FieldType>
490 for (
int i=0; i<matrix.N(); i++)
491 for (
int j=0; j<matrix.M(); j++) {
494 MatlabPODWriter<FieldType>::write(matrix[i][j],
s)<< std::endl;
505 template <
class MatrixType>
511 std::vector<typename MatrixType::size_type>
colOffset(matrix.M());
515 for (
typename MatrixType::size_type i=0; i<matrix.M()-1; i++)
519 typename MatrixType::size_type
rowOffset = 0;
525 const typename MatrixType::row_type& row = matrix[
rowIdx];
527 typename MatrixType::row_type::ConstIterator
cIt = row.begin();
528 typename MatrixType::row_type::ConstIterator
cEndIt = row.end();
561 template <
class MatrixType>
Implementation of the BCRSMatrix class.
A dynamic dense block matrix class.
Some handy generic functions for ISTL matrices.
This file implements a quadratic matrix of fixed size which is a multiple of the identity.
Col col
Definition matrixmatrix.hh:347
Matrix & mat
Definition matrixmatrix.hh:343
void writeMatrixToMatlab(const MatrixType &matrix, const std::string &filename, int outputPrecision=18)
Writes sparse matrix in a Matlab-readable format.
Definition io.hh:562
void recursive_printvector(std::ostream &s, const V &v, std::string rowtext, int &counter, int columns, int width, int precision)
Recursively print all the blocks.
Definition io.hh:53
void printmatrix(std::ostream &s, const M &A, std::string title, std::string rowtext, int width=10, int precision=2)
Print a generic block matrix.
Definition io.hh:259
void printvector(std::ostream &s, const V &v, std::string title, std::string rowtext, int columns=1, int width=10, int precision=2)
Print an ISTL vector.
Definition io.hh:102
void print_row(std::ostream &s, const M &A, typename M::size_type I, typename M::size_type J, typename M::size_type therow, int width, int precision)
Print one row of a matrix.
Definition io.hh:165
void printSparseMatrix(std::ostream &s, const BCRSMatrix< FieldMatrix< B, n, m >, A > &mat, std::string title, std::string rowtext, int width=3, int precision=2)
Prints a BCRSMatrix with fixed sized blocks.
Definition io.hh:317
void fill_row(std::ostream &s, int m, int width, int precision)
Print a row of zeros for a non-existing block.
Definition io.hh:146
void writeMatrixToMatlabHelper(const ScaledIdentityMatrix< FieldType, dim > &matrix, int rowOffset, int colOffset, std::ostream &s)
Helper method for the writeMatrixToMatlab routine.
Definition io.hh:425
Definition basearray.hh:19
Iterator implementation class
Definition basearray.hh:84
Definition matrixutils.hh:231
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
A sparse block matrix with compressed row storage.
Definition bcrsmatrix.hh:412
ConstIterator class for sequential access.
Definition matrix.hh:398
A generic dynamic dense matrix.
Definition matrix.hh:555
RowIterator end()
Get iterator to one beyond last row.
Definition matrix.hh:615
RowIterator begin()
Get iterator to first row.
Definition matrix.hh:609
size_type M() const
Return the number of columns.
Definition matrix.hh:695
size_type N() const
Return the number of rows.
Definition matrix.hh:690
Definition matrixutils.hh:25