dune-common
2.2.1
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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=8 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/misc.hh
>
12
#include <
dune/common/exceptions.hh
>
13
#include <
dune/common/dynvector.hh
>
14
#include <
dune/common/densematrix.hh
>
15
#include <
dune/common/static_assert.hh
>
16
17
namespace
Dune
18
{
19
29
template
<
class
K >
class
DynamicMatrix
;
30
31
template
<
class
K >
32
struct
DenseMatVecTraits
<
DynamicMatrix
<K> >
33
{
34
typedef
DynamicMatrix<K>
derived_type
;
35
36
typedef
DynamicVector<K>
row_type
;
37
38
typedef
row_type
&
row_reference
;
39
typedef
const
row_type
&
const_row_reference
;
40
41
typedef
std::vector<K>
container_type
;
42
typedef
K
value_type
;
43
typedef
typename
container_type::size_type
size_type
;
44
};
45
46
template
<
class
K >
47
struct
FieldTraits
<
DynamicMatrix
<K> >
48
{
49
typedef
typename
FieldTraits<K>::field_type
field_type
;
50
typedef
typename
FieldTraits<K>::real_type
real_type
;
51
};
52
57
template
<
class
K>
58
class
DynamicMatrix
:
public
DenseMatrix
< DynamicMatrix<K> >
59
{
60
std::vector< DynamicVector<K> > _data;
61
typedef
DenseMatrix< DynamicMatrix<K>
> Base;
62
public
:
63
typedef
typename
Base::size_type
size_type
;
64
typedef
typename
Base::value_type
value_type
;
65
typedef
typename
Base::row_type
row_type
;
66
67
//===== constructors
69
DynamicMatrix
() {}
70
72
DynamicMatrix
(
size_type
r,
size_type
c
,
value_type
v =
value_type
() ) :
73
_data(r,
row_type
(c, v) )
74
{}
75
76
//==== resize related methods
77
void
resize
(
size_type
r,
size_type
c,
value_type
v =
value_type
() )
78
{
79
_data.resize(0);
80
_data.resize(r,
row_type
(c, v) );
81
}
82
83
//===== assignment
84
using
Base::operator=;
85
86
// make this thing a matrix
87
size_type
mat_rows
()
const
{
return
_data.size(); }
88
size_type
mat_cols
()
const
{
89
assert(this->
rows
());
90
return
_data.front().size();
91
}
92
row_type
&
mat_access
(
size_type
i) {
return
_data[i]; }
93
const
row_type
&
mat_access
(
size_type
i)
const
{
return
_data[i]; }
94
};
95
98
}
// end namespace
99
100
#endif
Generated on Sun May 12 2013 23:19:48 for dune-common by
1.8.3.1