| 1 |
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 |
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 3 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 4 |
// vi: set et ts=4 sw=2 sts=2: |
| 5 |
#include <dune/istl/bcrsmatrix.hh> |
| 6 |
#include <dune/common/fmatrix.hh> |
| 7 |
#include <dune/common/test/iteratortest.hh> |
| 8 |
#include <iostream> |
| 9 |
|
| 10 |
class RowFunc { |
| 11 |
public: |
| 12 |
void operator()(const Dune::FieldMatrix<double,1,1>& t){ |
| 13 |
std::cout << t <<" "; |
| 14 |
} |
| 15 |
}; |
| 16 |
|
| 17 |
class MatrixFunc |
| 18 |
{ |
| 19 |
public: |
| 20 |
void operator()(const Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >::row_type& row) |
| 21 |
{ |
| 22 |
std::cout << *(row.begin())<<" "; |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
int main() |
| 27 |
{ |
| 28 |
using namespace Dune; |
| 29 |
|
| 30 |
typedef BCRSMatrix<FieldMatrix<double,1,1> > M; |
| 31 |
|
| 32 |
BCRSMatrix<FieldMatrix<double,1,1> > bcrsMatrix(3,3, BCRSMatrix<FieldMatrix<double,1,1> >::random); |
| 33 |
|
| 34 |
bcrsMatrix.setrowsize(0,1); |
| 35 |
bcrsMatrix.setrowsize(1,2); |
| 36 |
bcrsMatrix.setrowsize(2,2); |
| 37 |
|
| 38 |
bcrsMatrix.endrowsizes(); |
| 39 |
|
| 40 |
bcrsMatrix.addindex(0, 0); |
| 41 |
bcrsMatrix.addindex(1, 1); |
| 42 |
bcrsMatrix.addindex(1, 0); |
| 43 |
bcrsMatrix.addindex(2, 2); |
| 44 |
bcrsMatrix.addindex(2, 1); |
| 45 |
bcrsMatrix.endindices(); |
| 46 |
|
| 47 |
bcrsMatrix = 0; |
| 48 |
|
| 49 |
MatrixFunc mf; |
| 50 |
RowFunc rf; |
| 51 |
|
| 52 |
return testIterator<M,MatrixFunc,false>(bcrsMatrix,mf) + testIterator<M::row_type,RowFunc,false>(bcrsMatrix[1], rf); |
| 53 |
} |