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

Function chebyquad_derivative

dlib/test/optimization_test_functions.cpp:81–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 // ----------------------------------------------------------------------------------------
80
81 matrix<double,0,1> chebyquad_derivative (const matrix<double,0,1>& x)
82 {
83 const int n = x.size();
84 matrix<double,0,1> fvec = chebyquad_residuals(x);
85 matrix<double,0,1> g(n);
86 int i;
87 int j;
88 double s1;
89 double s2;
90 double t;
91 double t1;
92 double t2;
93 double th;
94
95 for (j = 1; j <= n; ++j)
96 {
97 g(j-1) = 0.0E+00;
98 t1 = 1.0E+00;
99 t2 = 2.0E+00 * x(j-1) - 1.0E+00;
100 t = 2.0E+00 * t2;
101 s1 = 0.0E+00;
102 s2 = 2.0E+00;
103 for (i = 1; i <= n; ++i)
104 {
105 g(j-1) = g(j-1) + fvec(i-1) * s2;
106 th = 4.0E+00 * t2 + t * s2 - s1;
107 s1 = s2;
108 s2 = th;
109 th = t * t2 - t1;
110 t1 = t2;
111 t2 = th;
112 }
113 }
114
115 g = 2.0E+00 * g / (double) ( n );
116
117 return g;
118 }
119
120 // ----------------------------------------------------------------------------------------
121

Callers 3

test_problemsFunction · 0.85
test_with_chebyquadFunction · 0.85

Calls 3

chebyquad_residualsFunction · 0.85
xFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected