2014-03-03 12:41:48 +00:00
|
|
|
/*
|
|
|
|
* Model.hpp, part of LatAnalyze 3
|
|
|
|
*
|
2016-04-06 20:11:23 +01:00
|
|
|
* Copyright (C) 2013 - 2016 Antonin Portelli
|
2014-03-03 12:41:48 +00:00
|
|
|
*
|
|
|
|
* 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_Model_hpp_
|
|
|
|
#define Latan_Model_hpp_
|
|
|
|
|
2014-03-13 18:51:01 +00:00
|
|
|
#include <LatAnalyze/Global.hpp>
|
2019-02-10 00:23:36 +00:00
|
|
|
#include <LatAnalyze/Functional/Function.hpp>
|
|
|
|
#include <LatAnalyze/Core/Mat.hpp>
|
2014-03-03 12:41:48 +00:00
|
|
|
|
2015-01-28 17:15:05 +00:00
|
|
|
BEGIN_LATAN_NAMESPACE
|
2014-03-03 12:41:48 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Double model class *
|
|
|
|
******************************************************************************/
|
|
|
|
class DoubleModel
|
|
|
|
{
|
2015-01-28 17:15:05 +00:00
|
|
|
public:
|
2014-03-03 12:41:48 +00:00
|
|
|
typedef std::function<double(const double *, const double *)> vecFunc;
|
2015-01-28 17:15:05 +00:00
|
|
|
private:
|
2014-03-03 17:01:07 +00:00
|
|
|
struct ModelSize{Index nArg, nPar;};
|
2014-03-03 12:41:48 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
2015-02-24 17:00:19 +00:00
|
|
|
DoubleModel(const vecFunc &f = nullptr, const Index nArg = 0,
|
|
|
|
const Index nPar = 0);
|
2014-03-03 12:41:48 +00:00
|
|
|
// destructor
|
|
|
|
virtual ~DoubleModel(void) = default;
|
|
|
|
// access
|
2016-03-31 12:12:30 +01:00
|
|
|
virtual Index getNArg(void) const;
|
|
|
|
virtual Index getNPar(void) const;
|
|
|
|
void setFunction(const vecFunc &f, const Index nArg,
|
|
|
|
const Index nPar);
|
|
|
|
VarName & varName(void);
|
|
|
|
const VarName & varName(void) const;
|
|
|
|
VarName & parName(void);
|
|
|
|
const VarName & parName(void) const;
|
2014-03-03 12:41:48 +00:00
|
|
|
// function call
|
|
|
|
double operator()(const DVec &data, const DVec &par) const;
|
|
|
|
double operator()(const std::vector<double> &data,
|
|
|
|
const std::vector<double> &par) const;
|
2015-02-24 17:00:19 +00:00
|
|
|
double operator()(const double *data, const double *par) const;
|
2015-01-28 17:19:57 +00:00
|
|
|
// bind
|
|
|
|
DoubleFunction fixArg(const DVec &arg) const;
|
|
|
|
DoubleFunction fixPar(const DVec &par) const;
|
|
|
|
DoubleFunction toFunction(void) const;
|
2014-03-03 12:41:48 +00:00
|
|
|
private:
|
|
|
|
// error checking
|
|
|
|
void checkSize(const Index nArg, const Index nPar) const;
|
|
|
|
private:
|
|
|
|
std::shared_ptr<ModelSize> size_;
|
2016-03-31 12:12:30 +01:00
|
|
|
VarName varName_, parName_;
|
2014-03-03 12:41:48 +00:00
|
|
|
vecFunc f_;
|
|
|
|
};
|
|
|
|
|
2015-02-24 17:00:19 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* base class for model factories *
|
|
|
|
******************************************************************************/
|
|
|
|
class DoubleModelFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
DoubleModelFactory(void) = default;
|
|
|
|
// destructor
|
|
|
|
virtual ~DoubleModelFactory(void) = default;
|
|
|
|
// factory
|
|
|
|
virtual DoubleModel makeModel(const bool makeHardCopy) const = 0;
|
|
|
|
};
|
|
|
|
|
2015-01-28 17:15:05 +00:00
|
|
|
END_LATAN_NAMESPACE
|
2014-03-03 12:41:48 +00:00
|
|
|
|
|
|
|
#endif // Latan_Model_hpp_
|