00001
00002
00003
00004 #ifndef FITYK__SUM__H__
00005 #define FITYK__SUM__H__
00006 #include <vector>
00007 #include <string>
00008 #include <utility>
00009 #include <memory>
00010 #include "common.h"
00011
00012 class Function;
00013 class Data;
00014 class VariableManager;
00015 class Ftk;
00016
00017 struct FunctionSum
00018 {
00019
00020 std::vector<std::string> names;
00021
00022 std::vector<int> idx;
00023
00024 bool empty() const { return names.empty(); }
00025 };
00026
00027
00028
00029
00030 class Model
00031 {
00032 public:
00033 Model(Ftk *F);
00034 ~Model();
00035
00036
00037 realt value(realt x) const;
00038
00039
00040
00041 void compute_model(std::vector<realt> &x, std::vector<realt> &y,
00042 int ignore_func=-1) const;
00043
00044
00045 void compute_model_with_derivs(std::vector<realt> &x, std::vector<realt> &y,
00046 std::vector<realt> &dy_da) const;
00047
00048
00049
00050 realt approx_max(realt x_min, realt x_max) const;
00051
00052 std::string get_formula(bool simplify) const;
00053 std::string get_peak_parameters(const std::vector<realt>& errors) const;
00054 std::vector<realt> get_symbolic_derivatives(realt x) const;
00055 std::vector<realt> get_numeric_derivatives(realt x, realt numerical_h)const;
00056 realt zero_shift(realt x) const;
00057
00058
00059 const FunctionSum& get_ff() const { return ff_; }
00060 FunctionSum& get_ff() { return ff_; }
00061 const FunctionSum& get_zz() const { return zz_; }
00062 FunctionSum& get_zz() { return zz_; }
00063 const FunctionSum& get_fz(char c) const { return (c == 'F' ? ff_ : zz_); }
00064 FunctionSum& get_fz(char c) { return (c == 'F' ? ff_ : zz_); }
00065
00066
00067 const std::string& get_func_name(char c, int idx) const;
00068
00069 realt numarea(realt x1, realt x2, int nsteps) const;
00070 bool is_dependent_on_var(int idx) const;
00071
00072
00073 private:
00074 const Ftk* F_;
00075 VariableManager &mgr;
00076 FunctionSum ff_, zz_;
00077
00078 DISALLOW_COPY_AND_ASSIGN(Model);
00079 };
00080
00081
00082 #endif
00083