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

Function unconstrained_gradient_magnitude

dlib/test/optimization.cpp:922–944  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920
921 template <typename der_funct, typename T>
922 double unconstrained_gradient_magnitude (
923 const der_funct& grad,
924 const T& x,
925 const T& lower,
926 const T& upper
927 )
928 {
929 T g = grad(x);
930
931 double unorm = 0;
932
933 for (long i = 0; i < g.size(); ++i)
934 {
935 if (lower(i) < x(i) && x(i) < upper(i))
936 unorm += g(i)*g(i);
937 else if (x(i) == lower(i) && g(i) < 0)
938 unorm += g(i)*g(i);
939 else if (x(i) == upper(i) && g(i) > 0)
940 unorm += g(i)*g(i);
941 }
942
943 return unorm;
944 }
945
946 template <typename der_funct, typename T>
947 double unconstrained_gradient_magnitude_neg_funct (

Callers 2

test_bound_solver_rosenFunction · 0.85
test_bound_solver_brownFunction · 0.85

Calls 2

xFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected