UltraScan III
us_fit_worker.h
Go to the documentation of this file.
1 #ifndef US_EQFWORKER_H
2 #define US_EQFWORKER_H
3 
4 #include <QtCore>
5 
6 #include "us_extern.h"
7 #include "us_dataIO.h"
8 #include "us_matrix.h"
9 #include "us_math2.h"
10 #include "us_globeq_data.h"
11 #include "us_eqmath.h"
12 
13 #ifndef DbgLv
14 #define DbgLv(a) if(dbg_level>=a)qDebug()
15 #endif
16 
17 class US_FitWorker : public QThread
18 {
19  Q_OBJECT
20 
21  public:
22  US_FitWorker( US_EqMath*, FitCtrlPar&, QObject* parent );
23  ~US_FitWorker();
24 
25  void redefine_work( void ); // Redefine work parameters
26  void run ( void ); // Run the thread
27  void flag_paused ( bool ); // Set pause flag true/false
28  void flag_abort ( void ); // Set abort flag true
29 
30  signals:
31  void work_progress( int ); // Signal work progress step
32  void work_complete( void ); // Signal work complete
33 
34  private:
35  US_EqMath* emath; // EqMath object pointer
36  FitCtrlPar& fitpars; // Fit Control Parameters reference
37 
38  int dbg_level;
39  int mxiters; // Maximum iterations
40  int k_iter; // iteration count
41  int nlsmeth; // NLS method index
42  int modelx; // model type index
43  int ntpts; // number of total x,y data points
44  int ndsets; // number of data sets (scans)
45  int nfpars; // number of fit parameters per point
46 
47  double tolerance; // fit variance tolerance
48  double variance; // variance value (sum diffs. squared)
49  double old_vari; // previous iteration variance
50  double lambda; // current lambda value
51 
52  bool paused; // Flag pause/resume
53  bool abort; // Flag abort
54  bool aborted; // Flag fitting aborted
55  bool converged; // Flag fitting converged
56  bool completed; // Flag fitting completed
57 
58  private slots:
59  int fit_iterations( void ); // Main work method for fit iterations
60  int fit_iter_LM ( void ); // Fit iteration - Levenberg-Marquardt
61  int fit_iter_MGN ( void ); // Fit iteration - Modified Gauss-Newton
62  int fit_iter_HM ( void ); // Fit iteration - Hybrid Method
63  int fit_iter_QN ( void ); // Fit iteration - Quasi-Newton
64  int fit_iter_GLLS( void ); // Fit iteration - Generalized L LS
65  int fit_iter_NNLS( void ); // Fit iteration - NonNegative LS
66  void check_paused ( void );
67 
68  double linesearch ( double*, double );
69  double calc_testParameter( double*, double );
70  void updateQN ( double*, double* );
71  bool isNan ( double );
72 
73 };
74 #endif
75