QtiPlot  0.9.8.2
NonLinearFit.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : NonLinearFit.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : NonLinearFit class
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef NONLINEARFIT_H
00030 #define NONLINEARFIT_H
00031 
00032 #include "Fit.h"
00033 
00034 using namespace std;
00035 
00036 class NonLinearFit : public Fit
00037 {
00038     Q_OBJECT
00039 
00040     public:
00041         NonLinearFit(ApplicationWindow *parent, Graph *g);
00042         NonLinearFit(ApplicationWindow *parent, QwtPlotCurve *c);
00043         NonLinearFit(ApplicationWindow *parent, QwtPlotCurve *c, double start, double end);
00044         NonLinearFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00045         NonLinearFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00046         NonLinearFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 1, int endRow = -1);
00047 
00048         double eval(double *par, double x);
00049 
00050         virtual bool setParametersList(const QStringList& lst);
00051         virtual bool setFormula(const QString& s, bool = true);
00052 
00053         QMap<QString, double> constants(){return d_constants;};
00054         void setConstant(const QString& parName, double val);
00055         void removeConstant(const QString& parName){d_constants.remove(parName);};
00056         void removeConstants(){d_constants.clear();};
00057         int constantsCount(){return d_constants.size();};
00058         QList<QString> constantsList(){return d_constants.keys();};
00059         double constValue(const QString& name){return d_constants.value(name);};
00060 
00061         virtual QString legendInfo();
00062         static QStringList guessParameters(const QString& s, bool *error = 0, string *errMsg = 0, const QString& var = "x");
00063 
00064     protected:
00065         QString logFitInfo(int iterations, int status);
00066         FunctionCurve* insertFitFunctionCurve(const QString& name, int penWidth = 1, bool updateData = true);
00067 
00068     private:
00069         void calculateFitCurveData(double *X, double *Y);
00070         void init();
00071         virtual bool removeDataSingularities();
00072         void removePole(int index);
00073 
00074         QMap<QString, double> d_constants;
00075 };
00076 #endif