Skip to content
Snippets Groups Projects
Commit 52617735 authored by Christian Engwer's avatar Christian Engwer
Browse files

Merge branch 'feature/FS1659-Matlab-output-of-DynamicMatrix' into 'master'

Feature/fs1659 matlab output of dynamic matrix

fixed flyspray/FS#1659

See merge request !3
parents a1b1f072 66bd8914
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@
#include "istlexception.hh"
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/dynmatrix.hh>
#include <dune/common/diagonalmatrix.hh>
#include <dune/common/unused.hh>
......@@ -473,6 +474,27 @@ namespace Dune {
}
}
/**
* \brief Helper method for the writeMatrixToMatlab routine.
*
* \code
* #include <dune/istl/io.hh>
* \endcode
*
* This specialization for DynamicMatrices ends the recursion
*/
template <class FieldType>
void writeMatrixToMatlabHelper(const DynamicMatrix<FieldType>& matrix, int rowOffset,
int colOffset, std::ostream& s)
{
for (int i=0; i<matrix.N(); i++)
for (int j=0; j<matrix.M(); j++) {
//+1 for Matlab numbering
s << rowOffset + i + 1 << " " << colOffset + j + 1 << " ";
MatlabPODWriter<FieldType>::write(matrix[i][j], s)<< std::endl;
}
}
/**
* \brief Helper method for the writeMatrixToMatlab routine.
*
......
......@@ -8,6 +8,7 @@
#include <limits>
#include <dune/common/typetraits.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/dynmatrix.hh>
#include <dune/common/diagonalmatrix.hh>
#include <dune/common/unused.hh>
#include <dune/istl/scaledidmatrix.hh>
......@@ -361,6 +362,33 @@ namespace Dune
}
};
template <class T>
struct MatrixDimension<Dune::DynamicMatrix<T> >
{
typedef Dune::DynamicMatrix<T> MatrixType;
typedef typename MatrixType::size_type size_type;
static size_type rowdim(const MatrixType& /*A*/, size_type /*r*/)
{
return 1;
}
static size_type coldim(const MatrixType& /*A*/, size_type /*r*/)
{
return 1;
}
static size_type rowdim(const MatrixType& A)
{
return A.N();
}
static size_type coldim(const MatrixType& A)
{
return A.M();
}
};
template<typename K, int n, int m, typename TA>
struct MatrixDimension<Matrix<FieldMatrix<K,n,m>, TA> >
{
......
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