dune-istl  2.3beta2
bdmatrix.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_BLOCK_DIAGONAL_MATRIX_HH
4 #define DUNE_BLOCK_DIAGONAL_MATRIX_HH
5 
6 #include <memory>
7 
9 
15 namespace Dune {
25  template <class B, class A=std::allocator<B> >
26  class BDMatrix : public BCRSMatrix<B,A>
27  {
28  public:
29 
30  //===== type definitions and constants
31 
33  typedef typename B::field_type field_type;
34 
36  typedef B block_type;
37 
39  typedef A allocator_type;
40 
42  //typedef BCRSMatrix<B,A>::row_type row_type;
43 
45  typedef typename A::size_type size_type;
46 
48  enum {blocklevel = B::blocklevel+1};
49 
51  BDMatrix() : BCRSMatrix<B,A>() {}
52 
53  explicit BDMatrix(int size)
54  : BCRSMatrix<B,A>(size, size, BCRSMatrix<B,A>::random) {
55 
56  for (int i=0; i<size; i++)
57  this->BCRSMatrix<B,A>::setrowsize(i, 1);
58 
60 
61  for (int i=0; i<size; i++)
62  this->BCRSMatrix<B,A>::addindex(i, i);
63 
65 
66  }
67 
69  BDMatrix& operator= (const BDMatrix& other) {
70  this->BCRSMatrix<B,A>::operator=(other);
71  return *this;
72  }
73 
77  return *this;
78  }
79 
81  void invert() {
82  for (int i=0; i<this->N(); i++)
83  (*this)[i][i].invert();
84  }
85 
86  private:
87 
88  // ////////////////////////////////////////////////////////////////////////////
89  // The following methods from the base class should now actually be called
90  // ////////////////////////////////////////////////////////////////////////////
91 
92  // createbegin and createend should be in there, too, but I can't get it to compile
93  // BCRSMatrix<B,A>::CreateIterator createbegin () {}
94  // BCRSMatrix<B,A>::CreateIterator createend () {}
95  void setrowsize (size_type i, size_type s) {}
96  void incrementrowsize (size_type i) {}
97  void endrowsizes () {}
98  void addindex (size_type row, size_type col) {}
99  void endindices () {}
100  };
103 } // end namespace Dune
104 
105 #endif