| 34 | // ---------------------------------------------------------------------------------------- |
| 35 | |
| 36 | double rosen (const column_vector& m) |
| 37 | /* |
| 38 | This function computes what is known as Rosenbrock's function. It is |
| 39 | a function of two input variables and has a global minimum at (1,1). |
| 40 | So when we use this function to test out the optimization algorithms |
| 41 | we will see that the minimum found is indeed at the point (1,1). |
| 42 | */ |
| 43 | { |
| 44 | const double x = m(0); |
| 45 | const double y = m(1); |
| 46 | |
| 47 | // compute Rosenbrock's function and return the result |
| 48 | return 100.0*pow(y - x*x,2) + pow(1 - x,2); |
| 49 | } |
| 50 | |
| 51 | // This is a helper function used while optimizing the rosen() function. |
| 52 | const column_vector rosen_derivative (const column_vector& m) |