Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
mia
core
sparse_solver.hh
Go to the documentation of this file.
1
/* -*- mia-c++ -*-
2
*
3
* This file is part of MIA - a toolbox for medical image analysis
4
* Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
5
*
6
* MIA is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
#ifndef mia_core_sparse_solver_hh
22
#define mia_core_sparse_solver_hh
23
24
25
#include <
mia/core/product_base.hh
>
26
#include <
mia/core/traits.hh
>
27
28
NS_MIA_BEGIN
29
42
template
<
typename
F>
43
class
TSparseSolver
:
public
CProductBase
{
44
public
:
46
typedef
F
Field
;
47
49
typedef
F
plugin_data
;
50
52
typedef
typename
dim_traits<F>::dimsize_type
dimsize_type
;
53
55
typedef
TSparseSolver<F>
plugin_type
;
56
58
static
const
char
*
const
type_descr
;
59
61
typedef
typename
Field::iterator
field_iterator
;
62
64
typedef
typename
Field::const_iterator
const_field_iterator
;
65
67
typedef
typename
Field::value_type
value_type
;
68
76
class
A_mult_x
:
public
CProductBase
{
77
public
:
79
typedef
F
plugin_data
;
80
82
typedef
A_mult_x
plugin_type
;
83
85
static
const
char
*
const
type_descr
;
86
88
A_mult_x
():m_size(
dimsize_type
()){};
89
91
A_mult_x
(
const
dimsize_type
& size):m_size(size){};
92
94
virtual
~A_mult_x
() {};
95
105
virtual
value_type
operator ()
(
const_field_iterator
ix)
const
= 0;
106
110
virtual
int
get_boundary_size
()
const
= 0;
111
116
dimsize_type
get_size
()
const
{
117
return
m_size;
118
}
119
private
:
120
dimsize_type
m_size;
121
122
};
123
124
virtual
~TSparseSolver
() {};
125
126
134
virtual
int
solve
(
const
Field
& rhs,
Field
& x,
const
A_mult_x& mult)
const
= 0;
135
};
136
137
template
<
typename
F>
138
const
char
*
const
TSparseSolver<F>::type_descr
=
"sparsesolver"
;
139
140
141
template
<
typename
F>
142
const
char
*
const
TSparseSolver<F>::A_mult_x::type_descr
=
"amultx"
;
143
144
154
template
<
typename
F>
155
struct
multiply
{
162
static
void
apply
(F& MIA_PARAM_UNUSED(result),
163
const
typename
TSparseSolver<F>::A_mult_x
& MIA_PARAM_UNUSED(A),
const
F& MIA_PARAM_UNUSED(x)) {
164
static_assert(
sizeof
(F)==0,
"This operation needs to be specialized"
);
165
}
166
};
167
168
177
template
<
typename
F>
178
F
operator *
(
const
typename
TSparseSolver<F>::A_mult_x
& A,
const
F& x)
179
{
180
F result(x.get_size());
181
multiply<F>::apply
(result, A, x);
182
return
result;
183
}
184
185
186
NS_MIA_END
187
188
#endif
Generated on Tue Oct 15 2013 13:56:37 by
1.8.4