aboutsummaryrefslogtreecommitdiffstats
path: root/vmodels/powerlaw.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'vmodels/powerlaw.hpp')
-rw-r--r--vmodels/powerlaw.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/vmodels/powerlaw.hpp b/vmodels/powerlaw.hpp
new file mode 100644
index 0000000..1f05301
--- /dev/null
+++ b/vmodels/powerlaw.hpp
@@ -0,0 +1,50 @@
+#ifndef POWER_LAW_MODEL_H_
+#define POWER_LAW_MODEL_H_
+#define OPT_HEADER
+#include <core/fitter.hpp>
+#include <cmath>
+#include <misc/optvec.hpp>
+
+namespace opt_utilities
+{
+ template <typename T>
+ class powerlaw
+ :public model<optvec<T>,optvec<T>,optvec<T>,std::string>
+ {
+ private:
+ powerlaw* do_clone()const
+ {
+ return new powerlaw<T>(*this);
+ }
+
+ const char* do_get_type_name()const
+ {
+ return "1d power law";
+ }
+ public:
+ powerlaw()
+ {
+ this->push_param_info(param_info<optvec<T> >("Ampl",1));
+ this->push_param_info(param_info<optvec<T> >("gamma",1));
+ }
+
+ optvec<T> do_eval(const optvec<T>& x,const optvec<T>& param)
+ {
+ T A=get_element(param,0);
+ T gamma=get_element(param,1);
+ return A*pow(x,gamma);
+ }
+
+ private:
+ std::string do_get_information()const
+ {
+ return "Simple power law model\n"
+ "y=A*x^gamma\n";
+ }
+ };
+}
+
+
+
+#endif
+//EOF