dune-common
2.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
dynmatrix.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
// $Id: fmatrix.hh 6181 2010-10-13 18:53:40Z christi $
4
#ifndef DUNE_DYNMATRIX_HH
5
#define DUNE_DYNMATRIX_HH
6
7
#include <cmath>
8
#include <cstddef>
9
#include <iostream>
10
11
#include <
dune/common/exceptions.hh
>
12
#include <
dune/common/dynvector.hh
>
13
#include <
dune/common/densematrix.hh
>
14
#include <
dune/common/static_assert.hh
>
15
16
namespace
Dune
17
{
18
28
template
<
class
K >
class
DynamicMatrix;
29
30
template
<
class
K >
31
struct
DenseMatVecTraits
<
DynamicMatrix
<K> >
32
{
33
typedef
DynamicMatrix<K>
derived_type
;
34
35
typedef
DynamicVector<K>
row_type
;
36
37
typedef
row_type
&
row_reference
;
38
typedef
const
row_type
&
const_row_reference
;
39
40
typedef
std::vector<K>
container_type
;
41
typedef
K
value_type
;
42
typedef
typename
container_type::size_type
size_type
;
43
};
44
45
template
<
class
K >
46
struct
FieldTraits
<
DynamicMatrix
<K> >
47
{
48
typedef
typename
FieldTraits<K>::field_type
field_type
;
49
typedef
typename
FieldTraits<K>::real_type
real_type
;
50
};
51
56
template
<
class
K>
57
class
DynamicMatrix
:
public
DenseMatrix
< DynamicMatrix<K> >
58
{
59
std::vector< DynamicVector<K> > _data;
60
typedef
DenseMatrix< DynamicMatrix<K>
>
Base
;
61
public
:
62
typedef
typename
Base::size_type
size_type
;
63
typedef
typename
Base::value_type
value_type
;
64
typedef
typename
Base::row_type
row_type
;
65
66
//===== constructors
68
DynamicMatrix
() {}
69
71
DynamicMatrix
(
size_type
r,
size_type
c
,
value_type
v =
value_type
() ) :
72
_data(r,
row_type
(c, v) )
73
{}
74
75
//==== resize related methods
76
void
resize
(
size_type
r,
size_type
c,
value_type
v =
value_type
() )
77
{
78
_data.resize(0);
79
_data.resize(r,
row_type
(c, v) );
80
}
81
82
//===== assignment
83
using
Base::operator=;
84
85
// make this thing a matrix
86
size_type
mat_rows
()
const
{
return
_data.size(); }
87
size_type
mat_cols
()
const
{
88
assert(this->
rows
());
89
return
_data.front().size();
90
}
91
row_type
&
mat_access
(
size_type
i) {
return
_data[i]; }
92
const
row_type
&
mat_access
(
size_type
i)
const
{
return
_data[i]; }
93
};
94
97
}
// end namespace
98
99
#endif
Generated on Mon Feb 10 2014 23:52:37 for dune-common by
1.8.1.2