Skip to content
Snippets Groups Projects
Commit ab3ff5fc authored by Max Kahnt's avatar Max Kahnt
Browse files

Remove duplicate of SingleNonZeroColumnMatrix.

parent 3ba2c65e
Branches
No related tags found
No related merge requests found
...@@ -8,128 +8,7 @@ ...@@ -8,128 +8,7 @@
#include <dune/fufem/arithmetic.hh> #include <dune/fufem/arithmetic.hh>
#include <dune/fufem/indexedsliceiterator.hh> #include <dune/fufem/indexedsliceiterator.hh>
#include <dune/matrix-vector/singlenonzerocolumnmatrix.hh>
/**
* \brief A static matrix that has only a single nonzero column
*
* The number and values of this column are dynamic.
* For simplicity this derives from FieldMatrix and sets
* all entries accordingly. So it will not reduce memory
* requirements but allows to implement methods more efficiently.
*/
template<class K, int ROWS, int COLS>
class SingleNonZeroColumnMatrix
{
class RowProxy
{
public:
typedef std::size_t size_type;
typedef IndexedSliceIterator<const K*, const K> ConstIterator;
typedef ConstIterator const_iterator;
RowProxy(const K* value, size_type nzColIndex) :
value_(value),
nzColIndex_(nzColIndex)
{}
ConstIterator begin() const
{
return ConstIterator(value_, nzColIndex_, 0, 1);
}
ConstIterator end() const
{
return ConstIterator(value_, nzColIndex_+1, 0, 1);
}
protected:
const K* value_;
size_type nzColIndex_;
};
public:
enum { rows = ROWS, cols = COLS};
typedef RowProxy row_type;
typedef row_type const_row_reference;
typedef typename std::size_t size_type;
typedef typename RowProxy::ConstIterator ConstColIterator;
typedef typename Dune::FieldMatrix<K, ROWS, 1> SingleColumnMatrix;
/**
* \brief Create from single column matrix and column index
*/
SingleNonZeroColumnMatrix(const SingleColumnMatrix& c, size_type nzColIndex) :
nzCol_(c),
nzColIndex_(nzColIndex)
{}
size_type N() const
{
return ROWS;
}
size_type M() const
{
return COLS;
}
template<class X , class Y >
void umv(const X& x, Y& y) const
{
for(size_type i=0; i<N(); ++i)
y[i] += nzCol_[i] * x[nzColIndex_];
}
template<class X , class Y >
void umtv(const X& x, Y& y) const
{
for(size_type i=0; i<N(); ++i)
y[nzColIndex_] = nzCol_[i] * x[i];
}
template<class X , class Y >
void mtv(const X& x, Y& y) const
{
y = 0.0;
umtv(x, y);
}
const_row_reference operator[] (size_type rowIndex) const
{
return const_row_reference(&(nzCol_[rowIndex][0]), nzColIndex_);
}
size_type nonZeroColumnIndex() const
{
return nzColIndex_;
}
protected:
SingleColumnMatrix nzCol_;
const size_type nzColIndex_;
};
namespace Arithmetic
{
template<class K, int ROWS, int COLS>
struct MatrixTraits<SingleNonZeroColumnMatrix<K, ROWS, COLS> >
{
enum { isMatrix=true };
enum { isDense=false };
enum { hasStaticSize=true };
enum { rows=ROWS};
enum { cols=COLS};
};
};
/** /**
* \brief A static matrix that has only a single nonzero row * \brief A static matrix that has only a single nonzero row
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment