My Project
3d/fuzzyclustersolver_cg.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-2017 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 __SOLVERCG_HH
22#define __SOLVERCG_HH
23
24#ifdef HAVE_CONFIG_H
25#include <config.h>
26#endif
27
28#include <mia/3d.hh>
29#include <cstdio>
30#include <stdexcept>
31#include <string>
32
33
34
36
37using namespace std;
38
39
40
51extern bool fborder (long index, long nx, long ny, long nz);
52
66{
67
68private:
69
70 double __lambda1;
71 double __lambda2;
72
73 // Dimension of images
74 long __iter;
75 unsigned int __nx, __ny, __nz;
76 unsigned long __count;
77
78 // Pointer to Elements of w
79 float *__weight_imagePtr;
80 float *__fptr;
81 float *__gain_image_ptr;
82
83
84
85 // b and x for solution of system
86 double *__b;
87 double *__v;
88
89 // counts iterations
90
91
92 // help pointers for one iteration cycle
93 double *__r; // r^(k)
94 double *__rho; // p^(k)
95 double *__g;
96 double *__Ag; // speichert A * p
97 // Field of scaling factors
98 double *__scale;
99 double *__scale2;
100
101 // field for border voxels
102 bool *__border;
103
104
105 double __r1rho1; // speichert r1 * rho1
106 double __r2rho2; // speichert r2 * rho2
107 double __normr0;
108 double __q, __e, __sprod;
109
110 // minimal residuum
111 double __min_res, __relres;
112
115 void init();
116
117public:
127 solve_sCG (C3DFImage& w1, C3DFImage& f1, C3DFImage& g1, double l1, double l2, double r_res, double m_res);
128
130
136 int solve(long max_iterations, double *firstnormr0);
137
141 inline long get_iterations()
142 {
143 return __iter;
144 }
145
155 void multA(double *x, double *result, long start, long ende);
156
164 void multA_float(float *x, float *result);
165
170
175
181 void solvepar(long *max_iteration, double *normr, double *firstnormr0);
182
183};
184
186
187#endif
T3DImage< float > C3DFImage
3D image with signed 32 bit floating point values
Definition 3d/image.hh:521
a class providing a CG solver
void multA_float(float *x, float *result)
void add_to_solution(C3DFImage *e)
solve_sCG(C3DFImage &w1, C3DFImage &f1, C3DFImage &g1, double l1, double l2, double r_res, double m_res)
void multA(double *x, double *result, long start, long ende)
int solve(long max_iterations, double *firstnormr0)
void solvepar(long *max_iteration, double *normr, double *firstnormr0)
void get_solution(C3DFImage &gain)
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
bool fborder(long index, long nx, long ny, long nz)
function defining field borders