From cd463edb6e95e7b5eab8848e3438a8b07a6681b5 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Wed, 15 Feb 2012 15:35:43 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@220 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/opt.cc | 37 +++++++++++++++++++++++++++++++++++++ interface/opt.h | 2 ++ 2 files changed, 39 insertions(+) (limited to 'interface') diff --git a/interface/opt.cc b/interface/opt.cc index 7161cca..92906a1 100644 --- a/interface/opt.cc +++ b/interface/opt.cc @@ -50,6 +50,23 @@ struct fit_space std::vector model_names; +class func_obj_raw + :public func_obj > +{ +public: + double (*pfunc)(const double*); +private: + double do_eval(const std::vector& x) + { + return (*pfunc)(x.data()); + } + func_obj_raw* do_clone()const + { + return new func_obj_raw(*this); + } +}; + + void regist_model(const dopt::model& m,const char* addr) { @@ -76,6 +93,26 @@ public: extern "C" { + void optimize_powell_(double (*pfunc)(const double*),const int& np,double* params,const double& precision) + { + std::vector p(np); + for(int i=0;i > opt; + opt.set_func_obj(fo); + opt.set_opt_method(powell_method >()); + opt.set_start_point(p); + opt.set_precision(precision); + p=opt.optimize(); + for(int i=0;i