-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresfitter.h
More file actions
71 lines (60 loc) · 2.3 KB
/
resfitter.h
File metadata and controls
71 lines (60 loc) · 2.3 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef RESFITTER_H
#define RESFITTER_H
#define DEF_MAX_STEPS 1e2;
#define DEF_MIN_ERROR 1e-3;
#define DEF_MIN_NORM_DIFF 1e-3;
#define NOISE_LEVEL 0.25;
#include <vector>
#include "filedata.h"
#include <math.h>
#include <stack>
#include <iostream>
#include <QTime>
#include "Libs/Eigen/unsupported/Eigen/Polynomials"
#include <algorithm>
#include <cmath>
#include <complex>
#include <iterator>
using namespace std;
class ResFitter
{
int maxSteps;
double minError;
double step;
double minNormDiff;
vector<double> errors;
vector<double> freq;
vector<double> theta;
vector<struct Resonance> resData;
Resonance resonance;
double params[4] = {-1.0,-1.0,-1.0,-1.0};
FileData *file;
double lorentzDyc(double x, double xc, double w);
double lorentzDyc(double x, double *params);
double lorentzDxc(double x, double y0, double yc, double xc, double w);
double lorentzDxc(double x, double *params);
double lorentzDw(double x, double y0, double yc, double xc, double w);
double lorentzDw(double x, double *params);
double errorMSE(double *params);
void gradDescentStep(double *params);
void stochGradDescentStep(double *params, int numPoint);
void gradDescent();
bool readDataFromStack(stack <struct Resonance> & stack);
void findInitialParams(double y0);
double findStep(double* initialParams, double* gradient, int numPoint);
vector<double> eigenSolver(const std::vector<double>& coeffA);
vector<double> eigenSolverMonic(const std::vector<double>& coefficients);
int randInt();
public:
vector<struct Resonance> fittedData;
/*ResFitter - method that perform fitting data with Lorentz peak function. The result of fitting writes in text files.
* maxSteps - maximum number of steps that can be performed in gradient descend
* minError - the minimum error level that will stop the descend
* step - the value in gradient descend method y1 = y0 - step*grad
* file - element of class, that contain the fitting data*/
ResFitter(double maxSteps, double minError, FileData *file);
static double lorentz(double x, double *params);
void fitData(stack <struct Resonance> &stack, const vector<double> &baseline);
static double lorentz(double x, double y0, double yc, double xc, double w);
};
#endif // RESFITTER_H