/usr/include/dune/istl/bdmatrix.hh is in libdune-istl-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #ifndef DUNE_BLOCK_DIAGONAL_MATRIX_HH
#define DUNE_BLOCK_DIAGONAL_MATRIX_HH
#include <memory>
#include <dune/istl/bcrsmatrix.hh>
/** \file
\author Oliver Sander
\brief Implementation of the BDMatrix class
*/
namespace Dune {
/**
* @addtogroup ISTL_SPMV
* @{
*/
/** \brief A block-diagonal matrix
\todo It would be safer and more efficient to have a real implementation of
a block-diagonal matrix and not just subclassing from BCRSMatrix. But that's
quite a lot of work for that little advantage.*/
template <class B, class A=std::allocator<B> >
class BDMatrix : public BCRSMatrix<B,A>
{
public:
//===== type definitions and constants
//! export the type representing the field
typedef typename B::field_type field_type;
//! export the type representing the components
typedef B block_type;
//! export the allocator type
typedef A allocator_type;
//! implement row_type with compressed vector
//typedef BCRSMatrix<B,A>::row_type row_type;
//! The type for the index access and the size
typedef typename A::size_type size_type;
//! increment block level counter
enum {blocklevel = B::blocklevel+1};
/** \brief Default constructor */
BDMatrix() : BCRSMatrix<B,A>() {}
explicit BDMatrix(int size)
: BCRSMatrix<B,A>(size, size, BCRSMatrix<B,A>::random) {
for (int i=0; i<size; i++)
this->BCRSMatrix<B,A>::setrowsize(i, 1);
this->BCRSMatrix<B,A>::endrowsizes();
for (int i=0; i<size; i++)
this->BCRSMatrix<B,A>::addindex(i, i);
this->BCRSMatrix<B,A>::endindices();
}
//! assignment
BDMatrix& operator= (const BDMatrix& other) {
this->BCRSMatrix<B,A>::operator=(other);
return *this;
}
//! assignment from scalar
BDMatrix& operator= (const field_type& k) {
this->BCRSMatrix<B,A>::operator=(k);
return *this;
}
/** \brief Inverts the matrix */
void invert() {
for (int i=0; i<this->N(); i++)
(*this)[i][i].invert();
}
private:
// ////////////////////////////////////////////////////////////////////////////
// The following methods from the base class should now actually be called
// ////////////////////////////////////////////////////////////////////////////
// createbegin and createend should be in there, too, but I can't get it to compile
// BCRSMatrix<B,A>::CreateIterator createbegin () {}
// BCRSMatrix<B,A>::CreateIterator createend () {}
void setrowsize (size_type i, size_type s) {}
void incrementrowsize (size_type i) {}
void endrowsizes () {}
void addindex (size_type row, size_type col) {}
void endindices () {}
};
/** @}*/
} // end namespace Dune
#endif
|