aboutsummaryrefslogtreecommitdiffstats
path: root/models/constant.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'models/constant.hpp')
-rw-r--r--models/constant.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/models/constant.hpp b/models/constant.hpp
new file mode 100644
index 0000000..8d06279
--- /dev/null
+++ b/models/constant.hpp
@@ -0,0 +1,42 @@
+#ifndef CONSTANT_MODEL_H_
+#define CONSTANT_MODEL_H_
+#include <core/fitter.hpp>
+#include <cmath>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class constant
+ :public model<T,T,std::vector<T>,std::string>
+ {
+ private:
+ model<T,T,std::vector<T> >* do_clone()const
+ {
+ return new constant<T>(*this);
+ }
+ public:
+ constant()
+ {
+ this->push_param_info(param_info<std::vector<T> >("c",1));
+ }
+
+ public:
+ T do_eval(const T& x,const std::vector<T>& param)
+ {
+ //return x*param[0]+param[1];
+ return get_element(param,0);
+ }
+
+ private:
+ std::string do_to_string()const
+ {
+ return "Constant\n"
+ "y=C\n";
+ }
+ };
+};
+
+
+
+#endif
+//EOF