File indexing completed on 2025-01-26 03:34:20

0001 /*
0002     File                 : XYFitCurvePrivate.h
0003     Project              : LabPlot
0004     Description          : Private members of XYFitCurve
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2014-2021 Alexander Semke <alexander.semke@web.de>
0007     SPDX-FileCopyrightText: 2022 Stefan Gerlach <stefan.gerlach@uni.kn>
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef XYFITCURVEPRIVATE_H
0012 #define XYFITCURVEPRIVATE_H
0013 
0014 #include "backend/worksheet/plots/cartesian/XYAnalysisCurvePrivate.h"
0015 #include "backend/worksheet/plots/cartesian/XYFitCurve.h"
0016 
0017 class XYFitCurve;
0018 class Column;
0019 class Histogram;
0020 
0021 #include <gsl/gsl_multifit_nlin.h>
0022 
0023 class XYFitCurvePrivate : public XYAnalysisCurvePrivate {
0024 public:
0025     explicit XYFitCurvePrivate(XYFitCurve*);
0026     ~XYFitCurvePrivate() override;
0027 
0028     virtual bool recalculateSpecific(const AbstractColumn* tmpXDataColumn, const AbstractColumn* tmpYDataColumn) override;
0029     virtual void prepareTmpDataColumn(const AbstractColumn** tmpXDataColumn, const AbstractColumn** tmpYDataColumn) override;
0030     virtual void resetResults() override;
0031     void runLevenbergMarquardt(const AbstractColumn* xcol, const AbstractColumn* ycol, Range<double> xRange);
0032     void runMaximumLikelihood(const AbstractColumn* xcol, double normalization);
0033     bool evaluate(bool preview = false);
0034 
0035     const Histogram* dataSourceHistogram{nullptr};
0036     QString dataSourceHistogramPath;
0037     const AbstractColumn* xErrorColumn{nullptr}; //<! column storing the values for the x-error to be used in the fit
0038     const AbstractColumn* yErrorColumn{nullptr}; //<! column storing the values for the y-error to be used in the fit
0039     QString xErrorColumnPath;
0040     QString yErrorColumnPath;
0041 
0042     XYFitCurve::FitData fitData;
0043     XYFitCurve::FitResult fitResult;
0044     QStringList solverOutput;
0045 
0046     Column* residualsColumn{nullptr};
0047     QVector<double>* residualsVector{nullptr};
0048 
0049     XYFitCurve* const q;
0050 
0051 private:
0052     void prepareResultColumns();
0053     void writeSolverState(gsl_multifit_fdfsolver*, double chi = qQNaN());
0054 };
0055 
0056 #endif