aboutsummaryrefslogtreecommitdiffstats
path: root/vmodel/powerlaw.hpp
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-11-29 16:31:48 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-11-29 16:31:48 +0000
commit5a4dfd8ac3d47ceec08be073b7eaa318ea42e41d (patch)
treeb2903188dbf5cdbe39e5d8e2ffc287800c83c9da /vmodel/powerlaw.hpp
parent67688e30f4a5b3abfe34b3f96fd53168e3081242 (diff)
downloadopt-utilities-5a4dfd8ac3d47ceec08be073b7eaa318ea42e41d.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@100 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'vmodel/powerlaw.hpp')
-rw-r--r--vmodel/powerlaw.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/vmodel/powerlaw.hpp b/vmodel/powerlaw.hpp
new file mode 100644
index 0000000..1f05301
--- /dev/null
+++ b/vmodel/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