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

Function brown_derivative

dlib/test/optimization_test_functions.cpp:307–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305 // ----------------------------------------------------------------------------------------
306
307 matrix<double,4,1> brown_derivative ( const matrix<double,4,1>& x)
308 {
309 double c;
310 double df1dx1;
311 double df1dx2;
312 double df2dx3;
313 double df2dx4;
314 double f1;
315 double f2;
316 matrix<double,4,1> g;
317 int i;
318
319 g = 0;
320
321 for (i = 1; i <= 20; ++i)
322 {
323
324 c = double ( i ) / 5.0E+00;
325
326 f1 = x(0) + c * x(1) - std::exp ( c );
327 f2 = x(2) + std::sin ( c ) * x(3) - std::cos ( c );
328
329 df1dx1 = 1.0E+00;
330 df1dx2 = c;
331 df2dx3 = 1.0E+00;
332 df2dx4 = std::sin ( c );
333
334 using std::pow;
335 g(0) = g(0) + 4.0E+00 * ( pow(f1,3) * df1dx1 + f1 * pow(f2,2) * df1dx1 );
336 g(1) = g(1) + 4.0E+00 * ( pow(f1,3) * df1dx2 + f1 * pow(f2,2) * df1dx2 );
337 g(2) = g(2) + 4.0E+00 * ( pow(f1,2) * f2 * df2dx3 + pow(f2,3) * df2dx3 );
338 g(3) = g(3) + 4.0E+00 * ( pow(f1,2) * f2 * df2dx4 + pow(f2,3) * df2dx4 );
339
340 }
341
342 return g;
343 }
344
345 // ----------------------------------------------------------------------------------------
346

Callers 4

test_problemsFunction · 0.85
test_bound_solver_brownFunction · 0.85
test_with_brownFunction · 0.85

Calls 2

xFunction · 0.85
expFunction · 0.85

Tested by

no test coverage detected