This is a helper function used while optimizing the rosen() function.
| 50 | |
| 51 | // This is a helper function used while optimizing the rosen() function. |
| 52 | const column_vector rosen_derivative (const column_vector& m) |
| 53 | /*! |
| 54 | ensures |
| 55 | - returns the gradient vector for the rosen function |
| 56 | !*/ |
| 57 | { |
| 58 | const double x = m(0); |
| 59 | const double y = m(1); |
| 60 | |
| 61 | // make us a column vector of length 2 |
| 62 | column_vector res(2); |
| 63 | |
| 64 | // now compute the gradient vector |
| 65 | res(0) = -400*x*(y-x*x) - 2*(1-x); // derivative of rosen() with respect to x |
| 66 | res(1) = 200*(y-x*x); // derivative of rosen() with respect to y |
| 67 | return res; |
| 68 | } |
| 69 | |
| 70 | // This function computes the Hessian matrix for the rosen() function. This is |
| 71 | // the matrix of second derivatives. |
no outgoing calls
no test coverage detected