3#ifndef DUNE_COLCOMPSPMATRIX_HH
4#define DUNE_COLCOMPSPMATRIX_HH
7#include <dune/istl/bccsmatrixinitializer.hh>
11#ifndef DUNE_ISTL_COLCOMPMATRIX_HH
14 template <
class M,
class RowIndex =
int>
15 struct ColCompMatrix :
public ISTL::Impl::BCCSMatrix< typename M::field_type, RowIndex>{};
22 template<
class M,
class RowIndex=
int>
23 struct ColCompMatrix {};
27#include <dune/fem/operator/matrix/spmatrix.hh>
37 template <
class T,
class IndexT,
class ValuesVector,
class IndicesVector,
class RowIndex>
38 class ColCompMatrix< Fem::SparseRowMatrix<T,IndexT,ValuesVector,IndicesVector>, RowIndex >
42 typedef ColCompMatrix< Fem::SparseRowMatrix<T,IndexT,ValuesVector,IndicesVector>>
ThisType;
48 typedef RowIndex RowIndexType;
61 N_(0), M_(0), Nnz_(0), values_(0), rowindex_(0), colstart_(0)
107 ThisType& operator=(
const Matrix& mat)
115 ThisType& operator=(
const ThisType& mat)
124 colstart_=
new RowIndexType[M_+1];
125 for(size_type i=0; i<=M_; ++i)
126 colstart_[i]=mat.colstart[i];
130 values_ =
new T[Nnz_];
131 rowindex_ =
new RowIndexType[Nnz_];
132 for(size_type i=0; i<Nnz_; ++i)
133 values_[i]=mat.values[i];
134 for(size_type i=0; i<Nnz_; ++i)
135 rowindex_[i]=mat.rowindex[i];
158 colstart_=
new RowIndexType[M_+1];
159 for(size_type i=0;i!=(M_+1);++i)
163 for(size_type row=0; row < N_; ++row)
165 const size_type endRow = mat.endRow( row );
166 for( size_type col = mat.startRow( row ); col < endRow; ++col )
168 const auto pairIdx(mat.realValue( col ));
169 if( pairIdx.second!=Matrix::defaultCol )
171 ++(colstart_[pairIdx.second+1]);
178 std::vector<int> tempPos(M_,0);
179 for(size_type i=1;i!=(M_+1);++i)
181 colstart_[i]+=colstart_[i-1];
182 tempPos[i-1]=colstart_[i-1];
187 rowindex_=
new RowIndexType[Nnz_];
188 for(size_type row = 0; row < N_ ; ++ row)
190 const size_type endRow = mat.endRow( row );
191 for( size_type col = mat.startRow( row ); col < endRow; ++col )
193 const auto pairIdx(mat.realValue( col ));
194 if(pairIdx.second!=Matrix::defaultCol)
196 values_[tempPos[pairIdx.second]] = pairIdx.first;
197 rowindex_[tempPos[pairIdx.second]] = row ;
198 ++(tempPos[pairIdx.second]);
210 RowIndexType* rowindex_;
211 RowIndexType* colstart_;
void free()
Free allocated space.
Definition: colcompspmatrix.hh:141
virtual void setMatrix(const Matrix &mat)
Initialize data from given matrix.
Definition: colcompspmatrix.hh:152
RowIndexType * getColStart() const
Get the column start indices.
Definition: colcompspmatrix.hh:102
size_type M() const
Get the number of columns.
Definition: colcompspmatrix.hh:84
virtual ~ColCompMatrix()
Destructor.
Definition: colcompspmatrix.hh:65
ColCompMatrix(const Matrix &mat)
Constructor that initializes the data.
Definition: colcompspmatrix.hh:54
size_type nnz() const
Get the number of non zero entries.
Definition: colcompspmatrix.hh:78
Fem::SparseRowMatrix< T, IndexT, ValuesVector, IndicesVector > Matrix
The type of the matrix to convert.
Definition: colcompspmatrix.hh:44
size_type N() const
Get the number of rows.
Definition: colcompspmatrix.hh:72
ColCompMatrix()
Empty constructor.
Definition: colcompspmatrix.hh:60
ColCompMatrix< Fem::SparseRowMatrix< T, IndexT, ValuesVector, IndicesVector > > ThisType
The type of the matrix converted.
Definition: colcompspmatrix.hh:42
T * getValues() const
Get the non-zero entries of the matrix.
Definition: colcompspmatrix.hh:90
RowIndexType * getRowIndex() const
Get the row indices of the non-zero entries of the matrix.
Definition: colcompspmatrix.hh:96
SparseRowMatrix.
Definition: spmatrix.hh:40
IndexT size_type
matrix index type
Definition: spmatrix.hh:45
A generic dynamic dense matrix.
Definition: matrix.hh:561
Dune namespace.
Definition: alignedallocator.hh:13