MCPcopy Create free account
hub / github.com/davisking/dlib / rosen_derivative

Function rosen_derivative

examples/optimization_ex.cpp:52–68  ·  view source on GitHub ↗

This is a helper function used while optimizing the rosen() function.

Source from the content-addressed store, hash-verified

50
51// This is a helper function used while optimizing the rosen() function.
52const 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.

Callers 2

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected