3 #ifndef DUNE_COLCOMPSPMATRIX_HH 4 #define DUNE_COLCOMPSPMATRIX_HH 7 #include <dune/istl/colcompmatrix.hh> 49 N_(0), M_(0), Nnz_(0), values_(0), rowindex_(0), colstart_(0)
112 colstart_=
new int[M_+1];
113 for(
int i=0; i<=M_; ++i)
114 colstart_[i]=mat.colstart[i];
118 values_ =
new B[Nnz_];
119 rowindex_ =
new int[Nnz_];
120 for(
int i=0; i<Nnz_; ++i)
121 values_[i]=mat.values[i];
122 for(
int i=0; i<Nnz_; ++i)
123 rowindex_[i]=mat.rowindex[i];
146 colstart_=
new int[M_+1];
147 for(
int i=0;i!=(M_+1);++i)
151 for(
int i=0;i!=N_;++i)
156 const std::pair<B,int> pairIdx(mat.
realValue(count));
157 if(pairIdx.second>-1)
158 ++(colstart_[pairIdx.second+1]);
164 std::vector<int> tempPos(M_,0);
165 for(
int i=1;i!=(M_+1);++i)
167 colstart_[i]+=colstart_[i-1];
168 tempPos[i-1]=colstart_[i-1];
173 rowindex_=
new int[Nnz_];
175 for(
int i=0;i!=N_;++i)
180 const std::pair<B,int> pairIdx(mat.
realValue(count));
181 if(pairIdx.second>-1)
183 values_[tempPos[pairIdx.second]]=pairIdx.first;
184 rowindex_[tempPos[pairIdx.second]]=i;
185 ++(tempPos[pairIdx.second]);
204 #endif // #ifndef DUNE_COLCOMPSPMATRIX_HH Fem::SparseRowMatrix< B > Matrix
The type of the matrix to convert.
Definition: colcompspmatrix.hh:34
int cols() const
return number of columns
Definition: spmatrix.hh:246
virtual ~ColCompMatrix()
Destructor.
Definition: colcompspmatrix.hh:53
int size_type
Definition: colcompspmatrix.hh:36
ThisType & operator=(const ThisType &mat)
Definition: colcompspmatrix.hh:103
ColCompMatrix< Fem::SparseRowMatrix< B > > ThisType
The type of the matrix converted.
Definition: colcompspmatrix.hh:32
B * getValues() const
Get the non-zero entries of the matrix.
Definition: colcompspmatrix.hh:78
std::pair< T, int > realValue(int row, int fakeCol)
return pair< value, column >, used by BlockMatrix
Definition: spmatrix.hh:202
ThisType & operator=(const Matrix &mat)
Definition: colcompspmatrix.hh:95
int numNonZeros() const
return max number of non zeros
Definition: spmatrix.hh:249
Definition: colcompspmatrix.hh:12
size_type nnz() const
Get the number of non zero entries.
Definition: colcompspmatrix.hh:66
Definition: coordinate.hh:4
SparseRowMatrix.
Definition: spmatrix.hh:104
ColCompMatrix()
Empty constructor.
Definition: colcompspmatrix.hh:48
int * getRowIndex() const
Get the row indices of the non-zero entries of the matrix.
Definition: colcompspmatrix.hh:84
int rows() const
return number of rows
Definition: spmatrix.hh:243
ColCompMatrix(const Matrix &mat)
Constructor that initializes the data.
Definition: colcompspmatrix.hh:42
size_type N() const
Get the number of rows.
Definition: colcompspmatrix.hh:60
int * getColStart() const
Get the column start indices.
Definition: colcompspmatrix.hh:90
size_type M() const
Get the number of columns.
Definition: colcompspmatrix.hh:72
virtual void setMatrix(const Matrix &mat)
Initialize data from given matrix.
Definition: colcompspmatrix.hh:140
void free()
Free allocated space.
Definition: colcompspmatrix.hh:129