dune-istl  2.1.1
bdmatrix.hh
Go to the documentation of this file.
00001 #ifndef DUNE_BLOCK_DIAGONAL_MATRIX_HH
00002 #define DUNE_BLOCK_DIAGONAL_MATRIX_HH
00003 
00004 #include <memory>
00005 
00006 #include <dune/istl/bcrsmatrix.hh>
00007 
00013 namespace Dune {
00023 template <class B, class A=std::allocator<B> >
00024 class BDMatrix : public BCRSMatrix<B,A>
00025 {
00026 public:
00027 
00028     //===== type definitions and constants
00029     
00031     typedef typename B::field_type field_type;
00032     
00034     typedef B block_type;
00035     
00037     typedef A allocator_type;
00038     
00040     //typedef BCRSMatrix<B,A>::row_type row_type;
00041 
00043     typedef typename A::size_type size_type;
00044 
00046     enum {blocklevel = B::blocklevel+1};
00047 
00049     BDMatrix() : BCRSMatrix<B,A>() {}
00050 
00051     explicit BDMatrix(int size) 
00052         : BCRSMatrix<B,A>(size, size, BCRSMatrix<B,A>::random) {
00053 
00054         for (int i=0; i<size; i++)
00055             this->BCRSMatrix<B,A>::setrowsize(i, 1);
00056 
00057         this->BCRSMatrix<B,A>::endrowsizes();
00058 
00059         for (int i=0; i<size; i++)
00060             this->BCRSMatrix<B,A>::addindex(i, i);
00061 
00062         this->BCRSMatrix<B,A>::endindices();
00063 
00064     }
00065 
00067     BDMatrix& operator= (const BDMatrix& other) {
00068         this->BCRSMatrix<B,A>::operator=(other);
00069         return *this;
00070     }
00071 
00073     BDMatrix& operator= (const field_type& k) {
00074         this->BCRSMatrix<B,A>::operator=(k);
00075         return *this;
00076     }
00077 
00079     void invert() {
00080         for (int i=0; i<this->N(); i++)
00081             (*this)[i][i].invert();
00082     }
00083 
00084 private:        
00085 
00086     // ////////////////////////////////////////////////////////////////////////////
00087     //   The following methods from the base class should now actually be called
00088     // ////////////////////////////////////////////////////////////////////////////
00089 
00090     // createbegin and createend should be in there, too, but I can't get it to compile
00091     //     BCRSMatrix<B,A>::CreateIterator createbegin () {}
00092     //     BCRSMatrix<B,A>::CreateIterator createend () {}
00093     void setrowsize (size_type i, size_type s) {}
00094     void incrementrowsize (size_type i) {}
00095     void endrowsizes () {}
00096     void addindex (size_type row, size_type col) {}
00097     void endindices () {}
00098 };
00101 }  // end namespace Dune
00102 
00103 #endif