1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-20 13:35:38 +01:00
LatAnalyze/latan/XYSampleData.hpp

112 lines
4.6 KiB
C++
Raw Normal View History

2014-03-12 19:24:15 +00:00
/*
* XYSampleData.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2014 Antonin Portelli
*
* LatAnalyze 3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze 3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef Latan_XYSampleData_hpp_
#define Latan_XYSampleData_hpp_
#include <latan/Global.hpp>
#include <latan/FitInterface.hpp>
#include <latan/Function.hpp>
#include <latan/MatSample.hpp>
#include <latan/Minimizer.hpp>
#include <latan/XYStatData.hpp>
BEGIN_NAMESPACE
/******************************************************************************
* object for fit result *
******************************************************************************/
class SampleFitResult: public DMatSample
{
friend class XYSampleData;
public:
// constructors
using DMatSample::DMatSample;
SampleFitResult(void) = default;
// destructor
virtual ~SampleFitResult(void) = default;
// access
double getChi2(const Index s) const;
const DSample & getChi2(const PlaceHolder ph = _) const;
double getChi2PerDof(const Index s) const;
DSample getChi2PerDof(const PlaceHolder ph = _) const;
const DoubleFunction & getModel(const Index s,
const Index j = 0) const;
const DoubleFunctionSample & getModel(const PlaceHolder ph = _,
const Index j = 0) const;
private:
DSample chi2_;
Index nDof_{0};
std::vector<DoubleFunctionSample> model_;
};
/******************************************************************************
* XYSampleData *
******************************************************************************/
class XYSampleData: public FitInterface
{
public:
typedef DMatSample::Block SampleBlock;
typedef DMatSample::ConstBlock ConstSampleBlock;
public:
// constructors
XYSampleData(void) = default;
XYSampleData(const Index nData, const Index xDim, const Index yDim,
const Index nSample);
// destructor
virtual ~XYSampleData(void) = default;
// access
const XYStatData & getData(const Index s = central);
void resize(const Index nData, const Index xDim,
const Index yDim, const Index nSample);
SampleBlock x(const PlaceHolder ph1, const PlaceHolder ph2);
ConstSampleBlock x(const PlaceHolder ph1, const PlaceHolder ph2) const;
SampleBlock x(const Index i, const PlaceHolder ph2 = _);
ConstSampleBlock x(const Index i, const PlaceHolder ph2 = _) const;
SampleBlock x(const PlaceHolder ph1, const Index k);
ConstSampleBlock x(const PlaceHolder ph1, const Index k) const;
SampleBlock x(const Index i, const Index k);
ConstSampleBlock x(const Index i, const Index k) const;
SampleBlock y(const PlaceHolder ph1, const PlaceHolder ph2);
ConstSampleBlock y(const PlaceHolder ph1, const PlaceHolder ph2) const;
SampleBlock y(const Index i, const PlaceHolder ph2 = _);
ConstSampleBlock y(const Index i, const PlaceHolder ph2 = _) const;
SampleBlock y(const PlaceHolder ph1, const Index k);
ConstSampleBlock y(const PlaceHolder ph1, const Index k) const;
SampleBlock y(const Index i, const Index k);
ConstSampleBlock y(const Index i, const Index k) const;
// fit
SampleFitResult fit(const std::vector<const DoubleModel *> &modelVector,
Minimizer &minimizer, const DVec &init,
const FitVerbosity verbosity = FitVerbosity::Silent);
SampleFitResult fit(const DoubleModel &model, Minimizer &minimizer,
const DVec &init,
const FitVerbosity verbosity = FitVerbosity::Silent);
private:
void setDataToSample(const Index s);
private:
bool isCovarianceInit_;
DMatSample x_, y_;
XYStatData data_;
};
END_NAMESPACE
#endif // Latan_XYSampleData_hpp_