dune-istl  2.2.1
bdmatrix.hh
Go to the documentation of this file.
1 #ifndef DUNE_BLOCK_DIAGONAL_MATRIX_HH
2 #define DUNE_BLOCK_DIAGONAL_MATRIX_HH
3 
4 #include <memory>
5 
7 
13 namespace Dune {
23 template <class B, class A=std::allocator<B> >
24 class BDMatrix : public BCRSMatrix<B,A>
25 {
26 public:
27 
28  //===== type definitions and constants
29 
31  typedef typename B::field_type field_type;
32 
34  typedef B block_type;
35 
37  typedef A allocator_type;
38 
40  //typedef BCRSMatrix<B,A>::row_type row_type;
41 
43  typedef typename A::size_type size_type;
44 
46  enum {blocklevel = B::blocklevel+1};
47 
49  BDMatrix() : BCRSMatrix<B,A>() {}
50 
51  explicit BDMatrix(int size)
52  : BCRSMatrix<B,A>(size, size, BCRSMatrix<B,A>::random) {
53 
54  for (int i=0; i<size; i++)
55  this->BCRSMatrix<B,A>::setrowsize(i, 1);
56 
58 
59  for (int i=0; i<size; i++)
60  this->BCRSMatrix<B,A>::addindex(i, i);
61 
63 
64  }
65 
67  BDMatrix& operator= (const BDMatrix& other) {
68  this->BCRSMatrix<B,A>::operator=(other);
69  return *this;
70  }
71 
75  return *this;
76  }
77 
79  void invert() {
80  for (int i=0; i<this->N(); i++)
81  (*this)[i][i].invert();
82  }
83 
84 private:
85 
86  // ////////////////////////////////////////////////////////////////////////////
87  // The following methods from the base class should now actually be called
88  // ////////////////////////////////////////////////////////////////////////////
89 
90  // createbegin and createend should be in there, too, but I can't get it to compile
91  // BCRSMatrix<B,A>::CreateIterator createbegin () {}
92  // BCRSMatrix<B,A>::CreateIterator createend () {}
93  void setrowsize (size_type i, size_type s) {}
94  void incrementrowsize (size_type i) {}
95  void endrowsizes () {}
96  void addindex (size_type row, size_type col) {}
97  void endindices () {}
98 };
101 } // end namespace Dune
102 
103 #endif