MCPcopy Create free account
hub / github.com/davisking/dlib / operator()

Method operator()

dlib/optimization/optimization.h:29–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28 template <typename T>
29 typename T::matrix_type operator()(const T& x) const
30 {
31 // T must be some sort of dlib matrix
32 COMPILE_TIME_ASSERT(is_matrix<T>::value);
33
34 typename T::matrix_type der(x.size());
35 typename T::matrix_type e(x);
36 for (long i = 0; i < x.size(); ++i)
37 {
38 const double old_val = e(i);
39
40 e(i) += eps;
41 const double delta_plus = f(e);
42 e(i) = old_val - eps;
43 const double delta_minus = f(e);
44
45 der(i) = (delta_plus - delta_minus)/((old_val+eps)-(old_val-eps));
46
47 // and finally restore the old value of this element
48 e(i) = old_val;
49 }
50
51 return der;
52 }
53
54 template <typename T, typename U>
55 typename U::matrix_type operator()(const T& item, const U& x) const

Callers

nothing calls this directly

Calls 3

derClass · 0.85
fFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected