aboutsummaryrefslogtreecommitdiffstats
path: root/interface/c_example.cc
diff options
context:
space:
mode:
Diffstat (limited to 'interface/c_example.cc')
-rw-r--r--interface/c_example.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/interface/c_example.cc b/interface/c_example.cc
new file mode 100644
index 0000000..0fb6d43
--- /dev/null
+++ b/interface/c_example.cc
@@ -0,0 +1,16 @@
+#include "opt.h"
+#include <iostream>
+using namespace std;
+
+double foo(const double* p)
+{
+ return p[0]*p[0]+(p[1]-1)*(p[1]-1);
+}
+
+int main()
+{
+ double p[2]={1000,1000};
+ optimize_powell(foo,2,p,1e-40);
+ optimize_powell(foo,2,p,1e-40);
+ cout<<p[0]<<"\t"<<p[1]<<endl;
+}