From 3a8b1ca89c9b62e35e24d414d7a79f4c325dfd09 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Sun, 1 Apr 2012 18:17:41 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@230 ed2142bd-67ad-457f-ba7c-d818d4011675 --- test/test_cg.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/test_cg.cpp (limited to 'test') diff --git a/test/test_cg.cpp b/test/test_cg.cpp new file mode 100644 index 0000000..a080cc5 --- /dev/null +++ b/test/test_cg.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +using namespace std; + +using namespace opt_utilities; + +class foo + :public diff_func_obj > +{ + foo* do_clone()const + { + return new foo(*this); + } + + double do_eval(const vector& p) + { + static int call_cnt=0; + ++call_cnt; + cerr< do_gradient(const vector& p) + { + static int call_cnt=0; + ++call_cnt; + cerr< result(p.size()); + for(int i=0;i > opt; + //opt.set_opt_method(conjugate_gradient >()); + opt.set_opt_method(powell_method >()); + opt.set_func_obj(foo()); + std::vector p(2); + p[0]=p[1]=4; + opt.set_start_point(p); + p=opt.optimize(); + cout<