00001
00002
00003
00004 #ifndef FITYK_UDF_H_
00005 #define FITYK_UDF_H_
00006
00007 #include "func.h"
00008 #include "mgr.h"
00009 #include "common.h"
00010
00011
00012 class CompoundFunction: public Function
00013 {
00014 public:
00015 CompoundFunction(const Settings* settings,
00016 const std::string &name,
00017 Tplate::Ptr tp,
00018 const std::vector<std::string> &vars);
00019 ~CompoundFunction();
00020 virtual void init();
00021
00022 void more_precomputations();
00023 void calculate_value_in_range(const std::vector<realt> &xx,
00024 std::vector<realt> &yy,
00025 int first, int last) const;
00026 void calculate_value_deriv_in_range(const std::vector<realt> &xx,
00027 std::vector<realt> &yy,
00028 std::vector<realt> &dy_da,
00029 bool in_dx,
00030 int first, int last) const;
00031 std::string get_current_formula(const std::string& x = "x") const;
00032 bool get_center(realt* a) const;
00033 bool get_height(realt* a) const;
00034 bool get_fwhm(realt* a) const;
00035 bool get_area(realt* a) const;
00036 bool get_nonzero_range(double level, realt& left, realt& right) const;
00037 void set_var_idx(const std::vector<Variable*>& variables);
00038
00039 protected:
00040 std::vector<Variable*> intern_variables_;
00041 std::vector<Function*> intern_functions_;
00042
00043 private:
00044 DISALLOW_COPY_AND_ASSIGN(CompoundFunction);
00045 };
00046
00047
00048
00049
00050 class CustomFunction: public Function
00051 {
00052 public:
00053 CustomFunction(const Settings* settings,
00054 const std::string &name,
00055 const Tplate::Ptr tp,
00056 const std::vector<std::string> &vars);
00057 ~CustomFunction();
00058
00059 void more_precomputations();
00060 void calculate_value_in_range(std::vector<realt> const &xx,
00061 std::vector<realt> &yy,
00062 int first, int last) const;
00063 void calculate_value_deriv_in_range(std::vector<realt> const &xx,
00064 std::vector<realt> &yy,
00065 std::vector<realt> &dy_da,
00066 bool in_dx,
00067 int first, int last) const;
00068 void set_var_idx(std::vector<Variable*> const& variables);
00069 std::string get_bytecode() const;
00070
00071
00072 private:
00073
00074
00075 mutable std::vector<realt> derivatives_;
00076
00077 VMData vm_;
00078 VMData substituted_vm_;
00079 int value_offset_;
00080
00081 DISALLOW_COPY_AND_ASSIGN(CustomFunction);
00082 };
00083
00084
00085
00086
00087 class SplitFunction: public Function
00088 {
00089 public:
00090 SplitFunction(const Settings* settings,
00091 const std::string &name,
00092 Tplate::Ptr tp,
00093 const std::vector<std::string> &vars);
00094 ~SplitFunction();
00095 virtual void init();
00096
00097
00098 void more_precomputations();
00099 void calculate_value_in_range(const std::vector<realt> &xx,
00100 std::vector<realt> &yy,
00101 int first, int last) const;
00102 void calculate_value_deriv_in_range(std::vector<realt> const &xx,
00103 std::vector<realt> &yy,
00104 std::vector<realt> &dy_da,
00105 bool in_dx,
00106 int first, int last) const;
00107 std::string get_current_formula(const std::string& x = "x") const;
00108 virtual bool get_center(realt* a) const;
00109 virtual bool get_height(realt* a) const;
00110 virtual bool get_fwhm(realt*) const { return false; }
00111 virtual bool get_area(realt*) const { return false; }
00112 bool get_nonzero_range(double level, realt& left, realt& right) const;
00113 void set_var_idx(const std::vector<Variable*>& variables);
00114
00115 private:
00116 std::vector<Variable*> intern_variables_;
00117 Function *left_, *right_;
00118
00119 DISALLOW_COPY_AND_ASSIGN(SplitFunction);
00120 };
00121
00122 #endif
00123