Skip to content
Snippets Groups Projects
Commit 80ab3e26 authored by Oliver Sander's avatar Oliver Sander
Browse files

Implement writeMatrixToMatlab if the inner type is a

ScaledIdMatrix or a DiagonalMatrix.

Patch by Uli Sack

[[Imported from SVN: r1636]]
parent 2caa0592
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@
#include <dune/common/fmatrix.hh>
#include <dune/istl/matrix.hh>
#include <dune/istl/diagonalmatrix.hh>
#include <dune/istl/scaledidmatrix.hh>
#include "bcrsmatrix.hh"
......@@ -391,6 +393,44 @@ namespace Dune {
};
} // anonymous namespace
//! Helper method for the writeMatrixToMatlab routine.
/**
* \code
*#include <dune/istl/io.hh>
* \endcode
*
* This specialization for DiagonalMatrices ends the recursion
*/
template <class FieldType, int dim>
void writeMatrixToMatlabHelper(const ScaledIdentityMatrix<FieldType,dim>& matrix, int rowOffset, int colOffset, std::ostream& s)
{
for (int i=0; i<dim; i++)
{
//+1 for Matlab numbering
s << rowOffset + i + 1 << " " << colOffset + i + 1 << " ";
MatlabPODWriter<FieldType>::write(matrix.scalar(), s)<< std::endl;
}
}
//! Helper method for the writeMatrixToMatlab routine.
/**
* \code
*#include <dune/istl/io.hh>
* \endcode
*
* This specialization for DiagonalMatrices ends the recursion
*/
template <class FieldType, int dim>
void writeMatrixToMatlabHelper(const DiagonalMatrix<FieldType,dim>& matrix, int rowOffset, int colOffset, std::ostream& s)
{
for (int i=0; i<dim; i++)
{
//+1 for Matlab numbering
s << rowOffset + i + 1 << " " << colOffset + i + 1 << " ";
MatlabPODWriter<FieldType>::write(matrix.diagonal(i), s)<< std::endl;
}
}
//! Helper method for the writeMatrixToMatlab routine.
/**
* \code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment