tfunctions.h - numeric - C++ library with numerical algorithms
(HTM) git clone git://src.adamsgaard.dk/numeric
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tfunctions.h (521B)
---
1 #include <functional>
2 #include <armadillo>
3 using namespace arma;
4 using namespace std;
5
6 int ncalls = 0;
7
8
9 // Rosenbrock's function
10 function<double(vec)> rosenbrock = [&ncalls] (vec p) {
11 ++ncalls;
12 double x = p[0], y = p[1];
13 return (1.0f - x) * (1.0f - x)
14 + 100.f * (y - x*x) * (y - x*x);
15 };
16
17 // Himmelblau's function
18 function<double(vec)> himmelblau = [&ncalls] (vec p) {
19 ++ncalls;
20 double x = p[0], y = p[1];
21 return (x*x + y - 11.0f) * (x*x + y - 11.0f)
22 + (x + y*y - 7.0f) * (x + y*y - 7.0f);
23 };
24