dune-fem  2.4.1-rc
fmatrixcol.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_COMMON_FMATRIXCOL_HH
2 #define DUNE_FEM_COMMON_FMATRIXCOL_HH
3 
4 #include <type_traits>
5 
6 #include <dune/common/densevector.hh>
7 #include <dune/common/fmatrix.hh>
8 
9 namespace Dune
10 {
11 
12  // Internal Forward Declarations
13  // -----------------------------
14 
15  template< class FieldMatrix >
17 
18 
19 
20  // DenseMatVecTraits for FieldMatrixColumn
21  // ---------------------------------------
22 
23  template< class FieldMatrix >
24  struct DenseMatVecTraits< FieldMatrixColumn< FieldMatrix > >
25  {
27 
28  typedef typename DenseMatVecTraits< typename std::remove_const< FieldMatrix >::type >::value_type value_type;
29  typedef typename DenseMatVecTraits< typename std::remove_const< FieldMatrix >::type >::size_type size_type;
30  };
31 
32 
33 
34  // FieldMatrixColumn
35  // -----------------
36 
37  template< class K, int m, int n >
38  class FieldMatrixColumn< FieldMatrix< K, m, n > >
39  : public DenseVector< FieldMatrixColumn< FieldMatrix< K, m, n > > >
40  {
41  typedef DenseVector< FieldMatrixColumn< FieldMatrix< K, m, n > > > Base;
42 
43  public:
44  static const int dimension = m;
45 
46  typedef typename Base::size_type size_type;
47  typedef typename Base::value_type value_type;
48 
49  FieldMatrixColumn ( FieldMatrix< K, m, n > &fieldMatrix, int column )
50  : fieldMatrix_( fieldMatrix ),
51  column_( column )
52  {}
53 
54  using Base::operator=;
55 
56  DUNE_CONSTEXPR size_type size () const { return vec_size(); }
57 
58  DUNE_CONSTEXPR size_type vec_size () const { return dimension; }
59  const value_type &vec_access ( size_type i ) const { return fieldMatrix_[ i ][ column_ ]; }
60  value_type &vec_access ( size_type i ) { return fieldMatrix_[ i ][ column_ ]; }
61 
62  private:
63  FieldMatrix< K, m, n > &fieldMatrix_;
64  int column_;
65  };
66 
67  template< class K, int m, int n >
68  class FieldMatrixColumn< const FieldMatrix< K, m, n > >
69  : public DenseVector< FieldMatrixColumn< const FieldMatrix< K, m, n > > >
70  {
71  typedef DenseVector< FieldMatrixColumn< const FieldMatrix< K, m, n > > > Base;
72 
73  public:
74  static const int dimension = m;
75 
76  typedef typename Base::size_type size_type;
77  typedef typename Base::value_type value_type;
78 
79  FieldMatrixColumn ( const FieldMatrix< K, m, n > &fieldMatrix, int column )
80  : fieldMatrix_( fieldMatrix ),
81  column_( column )
82  {}
83 
84  using Base::operator=;
85 
86  DUNE_CONSTEXPR size_type size () const { return vec_size(); }
87 
88  DUNE_CONSTEXPR size_type vec_size () const { return dimension; }
89  const value_type &vec_access ( size_type i ) const { return fieldMatrix_[ i ][ column_ ]; }
90 
91  private:
92  const FieldMatrix< K, m, n > &fieldMatrix_;
93  int column_;
94  };
95 
96 } // namespace Dune
97 
98 #endif // #ifndef DUNE_FEM_COMMON_FMATRIXCOL_HH
DUNE_CONSTEXPR size_type vec_size() const
Definition: fmatrixcol.hh:88
DenseMatVecTraits< typename std::remove_const< FieldMatrix >::type >::size_type size_type
Definition: fmatrixcol.hh:29
const value_type & vec_access(size_type i) const
Definition: fmatrixcol.hh:89
DUNE_CONSTEXPR size_type size() const
Definition: fmatrixcol.hh:56
Base::value_type value_type
Definition: fmatrixcol.hh:47
Base::value_type value_type
Definition: fmatrixcol.hh:77
FieldMatrixColumn(const FieldMatrix< K, m, n > &fieldMatrix, int column)
Definition: fmatrixcol.hh:79
FieldMatrixColumn(FieldMatrix< K, m, n > &fieldMatrix, int column)
Definition: fmatrixcol.hh:49
DUNE_CONSTEXPR size_type vec_size() const
Definition: fmatrixcol.hh:58
Definition: coordinate.hh:4
Definition: fmatrixcol.hh:16
FieldMatrixColumn< FieldMatrix > derived_type
Definition: fmatrixcol.hh:26
value_type & vec_access(size_type i)
Definition: fmatrixcol.hh:60
Base::size_type size_type
Definition: fmatrixcol.hh:76
DenseMatVecTraits< typename std::remove_const< FieldMatrix >::type >::value_type value_type
Definition: fmatrixcol.hh:28
DUNE_CONSTEXPR size_type size() const
Definition: fmatrixcol.hh:86
const value_type & vec_access(size_type i) const
Definition: fmatrixcol.hh:59
Base::size_type size_type
Definition: fmatrixcol.hh:46