DUNE-FEM (unstable)

fmatrixcol.hh
1#ifndef DUNE_FEM_COMMON_FMATRIXCOL_HH
2#define DUNE_FEM_COMMON_FMATRIXCOL_HH
3
4#include <type_traits>
5
8
9namespace Dune
10{
11
12 // Internal Forward Declarations
13 // -----------------------------
14
15 template< class FieldMatrix >
16 class FieldMatrixColumn;
17
18
19
20 // DenseMatVecTraits for FieldMatrixColumn
21 // ---------------------------------------
22
23 template< class FieldMatrix >
24 struct DenseMatVecTraits< FieldMatrixColumn< FieldMatrix > >
25 {
26 typedef FieldMatrixColumn< FieldMatrix > derived_type;
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 // FieldTraits for FieldMatrixColumn
34 // ---------------------------------
35
36 template< class FieldMatrix >
37 struct FieldTraits< FieldMatrixColumn< FieldMatrix > >
38 {
39 typedef typename FieldTraits< typename std::remove_const< FieldMatrix >::type >::field_type field_type;
40 typedef typename FieldTraits< typename std::remove_const< FieldMatrix >::type >::real_type real_type;
41 };
42
43
44
45 // FieldMatrixColumn
46 // -----------------
47
48 template< class K, int m, int n >
49 class FieldMatrixColumn< FieldMatrix< K, m, n > >
50 : public DenseVector< FieldMatrixColumn< FieldMatrix< K, m, n > > >
51 {
52 typedef DenseVector< FieldMatrixColumn< FieldMatrix< K, m, n > > > Base;
53
54 public:
55 static const int dimension = m;
56
57 typedef typename Base::size_type size_type;
58 typedef typename Base::value_type value_type;
59
60 FieldMatrixColumn ( FieldMatrix< K, m, n > &fieldMatrix, int column )
61 : fieldMatrix_( fieldMatrix ),
62 column_( column )
63 {}
64
65 using Base::operator=;
66
67 constexpr size_type size () const { return dimension; }
68
69 const value_type &operator[] ( size_type i ) const { return fieldMatrix_[ i ][ column_ ]; }
70 value_type &operator[] ( size_type i ) { return fieldMatrix_[ i ][ column_ ]; }
71
72 private:
73 FieldMatrix< K, m, n > &fieldMatrix_;
74 int column_;
75 };
76
77 template< class K, int m, int n >
78 class FieldMatrixColumn< const FieldMatrix< K, m, n > >
79 : public DenseVector< FieldMatrixColumn< const FieldMatrix< K, m, n > > >
80 {
81 typedef DenseVector< FieldMatrixColumn< const FieldMatrix< K, m, n > > > Base;
82
83 public:
84 static const int dimension = m;
85
86 typedef typename Base::size_type size_type;
87 typedef typename Base::value_type value_type;
88
89 FieldMatrixColumn ( const FieldMatrix< K, m, n > &fieldMatrix, int column )
90 : fieldMatrix_( fieldMatrix ),
91 column_( column )
92 {}
93
94 using Base::operator=;
95
96 constexpr size_type size () const { return dimension; }
97 const value_type &operator[] ( size_type i ) const { return fieldMatrix_[ i ][ column_ ]; }
98
99 private:
100 const FieldMatrix< K, m, n > &fieldMatrix_;
101 int column_;
102 };
103
104} // namespace Dune
105
106#endif // #ifndef DUNE_FEM_COMMON_FMATRIXCOL_HH
Implements the dense vector interface, with an exchangeable storage class.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)