My Project
2d/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/2d.hh>
29#include <cstdio>
30#include <stdexcept>
31#include <string>
32
33
34
36
37using namespace std;
38
39
40
48extern bool fborder (long index, long nx, long ny);
49
63{
64
65private:
66 double m_lambda1;
67 double m_lambda2;
68
69 // Dimension of images
70 long m_iter;
71 int m_nx, m_ny;
72 unsigned long m_count;
73
74 // Pointer to Elements of w
75 float *m_weight_imagePtr;
76 float *m_fptr;
77 float *m_gain_image_ptr;
78
79
80
81 // b and x for solution of system
82 std::vector<double> m_b;
83 std::vector<double> m_v;
84
85 // counts iterations
86
87
88 // help pointers for one iteration cycle
89 std::vector<double> m_r; // r^(k)
90 std::vector<double> m_rho; // p^(k)
91 std::vector<double> m_g;
92 std::vector<double> m_Ag; // speichert A * p
93 // Field of scaling factors
94 std::vector<double> m_scale;
95 std::vector<double> m_scale2;
96
97 // field for border voxels
98 std::vector<bool> m_border;
99
100
101 double m_r1rho1; // speichert r1 * rho1
102 double m_r2rho2; // speichert r2 * rho2
103 double m_normr0;
104 double m_q, m_e, m_sprod;
105
106 // minimal residuum
107 double m_min_res, m_relres;
108
111 void init();
112
113public:
123 C2DSolveCG (C2DFImage& w1, C2DFImage& f1, C2DFImage& g1, double l1, double l2, double r_res, double m_res);
124
126
132 int solve(long max_iterations, double *firstnormr0);
133
137 inline long get_iterations()
138 {
139 return m_iter;
140 }
141
151 void multA(std::vector<double>& x, std::vector<double>& result, long start, long ende);
152
160 void multA_float(float *x, float *result);
161
166
171
177 void solvepar(long *max_iteration, double *normr, double *firstnormr0);
178
179};
180
182
183#endif
bool fborder(long index, long nx, long ny)
function defining field borders
solve_sCG – a class providing a CG solver
void multA(std::vector< double > &x, std::vector< double > &result, long start, long ende)
void get_solution(C2DFImage &gain)
void solvepar(long *max_iteration, double *normr, double *firstnormr0)
int solve(long max_iterations, double *firstnormr0)
void add_to_solution(C2DFImage *e)
C2DSolveCG(C2DFImage &w1, C2DFImage &f1, C2DFImage &g1, double l1, double l2, double r_res, double m_res)
void multA_float(float *x, float *result)
#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