3d/fuzzyclustersolver_cg.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __SOLVERCG_HH
#define __SOLVERCG_HH
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <mia/3d.hh>
#include <cstdio>
#include <stdexcept>
#include <string>
NS_MIA_BEGIN
using namespace std;
extern bool fborder (long index, long nx, long ny, long nz);
class solve_sCG
{
private:
double __lambda1;
double __lambda2;
// Dimension of images
long __iter;
unsigned int __nx, __ny, __nz;
unsigned long __count;
// Pointer to Elements of w
float *__weight_imagePtr;
float *__fptr;
float *__gain_image_ptr;
// b and x for solution of system
double *__b;
double *__v;
// counts iterations
// help pointers for one iteration cycle
double *__r; // r^(k)
double *__rho; // p^(k)
double *__g;
double *__Ag; // speichert A * p
// Field of scaling factors
double *__scale;
double *__scale2;
// field for border voxels
bool *__border;
double __r1rho1; // speichert r1 * rho1
double __r2rho2; // speichert r2 * rho2
double __normr0;
double __q, __e, __sprod;
// minimal residuum
double __min_res, __relres;
void init();
public:
solve_sCG (C3DFImage& w1, C3DFImage& f1, C3DFImage& g1, double l1, double l2, double r_res, double m_res);
~solve_sCG();
int solve(long max_iterations, double *firstnormr0);
inline long get_iterations()
{
return __iter;
}
void multA(double *x, double *result, long start, long ende);
void multA_float(float *x, float *result);
void get_solution(C3DFImage& gain);
void add_to_solution(C3DFImage *e);
void solvepar(long *max_iteration, double *normr, double *firstnormr0);
};
NS_MIA_END
#endif
C3DFImage
T3DImage< float > C3DFImage
3D image with signed 32 bit floating point values
Definition 3d/image.hh:521
solve_sCG::get_iterations
long get_iterations()
Definition 3d/fuzzyclustersolver_cg.hh:141
solve_sCG::multA_float
void multA_float(float *x, float *result)
solve_sCG::add_to_solution
void add_to_solution(C3DFImage *e)
solve_sCG::~solve_sCG
~solve_sCG()
solve_sCG::solve_sCG
solve_sCG(C3DFImage &w1, C3DFImage &f1, C3DFImage &g1, double l1, double l2, double r_res, double m_res)
solve_sCG::multA
void multA(double *x, double *result, long start, long ende)
solve_sCG::solve
int solve(long max_iterations, double *firstnormr0)
solve_sCG::solvepar
void solvepar(long *max_iteration, double *normr, double *firstnormr0)
solve_sCG::get_solution
void get_solution(C3DFImage &gain)
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
fborder
bool fborder(long index, long nx, long ny, long nz)
function defining field borders
std
Definition gsl_iterator.hh:324