QtiPlot  0.9.8.2
NonLinearFit.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : NonLinearFit.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : NonLinearFit class
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef NONLINEARFIT_H
30 #define NONLINEARFIT_H
31 
32 #include "Fit.h"
33 
34 using namespace std;
35 
36 class NonLinearFit : public Fit
37 {
38  Q_OBJECT
39 
40  public:
42  NonLinearFit(ApplicationWindow *parent, QwtPlotCurve *c);
43  NonLinearFit(ApplicationWindow *parent, QwtPlotCurve *c, double start, double end);
44  NonLinearFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
45  NonLinearFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
46  NonLinearFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 1, int endRow = -1);
47 
48  double eval(double *par, double x);
49 
50  virtual bool setParametersList(const QStringList& lst);
51  virtual bool setFormula(const QString& s, bool = true);
52 
53  QMap<QString, double> constants(){return d_constants;};
54  void setConstant(const QString& parName, double val);
55  void removeConstant(const QString& parName){d_constants.remove(parName);};
56  void removeConstants(){d_constants.clear();};
57  int constantsCount(){return d_constants.size();};
58  QList<QString> constantsList(){return d_constants.keys();};
59  double constValue(const QString& name){return d_constants.value(name);};
60 
61  virtual QString legendInfo();
62  static QStringList guessParameters(const QString& s, bool *error = 0, string *errMsg = 0, const QString& var = "x");
63 
64  protected:
65  QString logFitInfo(int iterations, int status);
66  FunctionCurve* insertFitFunctionCurve(const QString& name, int penWidth = 1, bool updateData = true);
67 
68  private:
69  void calculateFitCurveData(double *X, double *Y);
70  void init();
71  virtual bool removeDataSingularities();
72  void removePole(int index);
73 
74  QMap<QString, double> d_constants;
75 };
76 #endif