-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function.h
48 lines (40 loc) · 1.48 KB
/
Function.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Class representing a correction function
//
// first version: Hartmut Stadie 2008/12/14
// $Id: Function.h,v 1.9 2010/11/24 09:50:21 stadie Exp $
//
#ifndef FUNCTION_H
#define FUNCTION_H
class Measurement;
class Parametrization;
class Function {
public:
typedef double (Parametrization::*ParametrizationFunction)(const Measurement*, const double*) const;
Function(ParametrizationFunction func, ParametrizationFunction invfunc,
double *firstpar, int parindex, int npars, const Parametrization* p)
: func_(func),invfunc_(invfunc),firstpar_(firstpar),parindex_(parindex),
npars_(npars)
{param_ = p; }
virtual ~Function() {}
virtual Function* clone() {
return new Function(*this);
}
double* firstPar() const { return firstpar_;}
int parIndex() const { return parindex_;}
int nPars() const { return npars_;}
double operator()(const Measurement* x) const { return (param_->*func_)(x,firstpar_);}
void changeParBase(double* oldpar, double* newpar) { firstpar_ += newpar - oldpar;}
bool hasInverse() const { return invfunc_;}
double inverse(const Measurement* x) const { return invfunc_ ? (param_->*invfunc_)(x,firstpar_) : 0;}
const ParametrizationFunction& parFunc() const { return func_;}
const Parametrization* parametrization() const { return param_;}
protected:
ParametrizationFunction func_;
ParametrizationFunction invfunc_;
double *firstpar_;
int parindex_;
int npars_;
static const Parametrization* param_;
};
#endif