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

Function unconstrained_gradient_magnitude_neg_funct

dlib/test/optimization.cpp:947–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945
946 template <typename der_funct, typename T>
947 double unconstrained_gradient_magnitude_neg_funct (
948 const der_funct& grad,
949 const T& x,
950 const T& lower,
951 const T& upper
952 )
953 {
954 T g = grad(x);
955
956 double unorm = 0;
957
958 for (long i = 0; i < g.size(); ++i)
959 {
960 if (lower(i) < x(i) && x(i) < upper(i))
961 unorm += g(i)*g(i);
962 else if (x(i) == lower(i) && g(i) > 0)
963 unorm += g(i)*g(i);
964 else if (x(i) == upper(i) && g(i) < 0)
965 unorm += g(i)*g(i);
966 }
967
968 return unorm;
969 }
970
971 template <typename search_strategy_type>
972 double test_bound_solver_neg_rosen (dlib::rand& rnd, search_strategy_type search_strategy)

Callers 1

Calls 2

xFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected