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

Function chebyquad_hessian

dlib/test/optimization_test_functions.cpp:166–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 // ----------------------------------------------------------------------------------------
165
166 matrix<double> chebyquad_hessian(const matrix<double,0,1>& x)
167 {
168 const int lda = x.size();
169 const int n = x.size();
170 double d1;
171 double d2;
172 matrix<double,0,1> fvec = chebyquad_residuals(x);
173 matrix<double,0,1> gvec(n);
174 matrix<double> h(lda,n);
175 int i;
176 int j;
177 int k;
178 double p1;
179 double p2;
180 double s1;
181 double s2;
182 double ss1;
183 double ss2;
184 double t;
185 double t1;
186 double t2;
187 double th;
188 double tt;
189 double tth;
190 double tt1;
191 double tt2;
192 h = 0;
193
194 d1 = 1.0E+00 / double ( n );
195 d2 = 2.0E+00 * d1;
196
197 for (j = 1; j <= n; ++j)
198 {
199
200 h(j-1,j-1) = 4.0E+00 * d1;
201 t1 = 1.0E+00;
202 t2 = 2.0E+00 * x(j-1) - 1.0E+00;
203 t = 2.0E+00 * t2;
204 s1 = 0.0E+00;
205 s2 = 2.0E+00;
206 p1 = 0.0E+00;
207 p2 = 0.0E+00;
208 gvec(0) = s2;
209
210 for (i = 2; i <= n; ++i)
211 {
212 th = 4.0E+00 * t2 + t * s2 - s1;
213 s1 = s2;
214 s2 = th;
215 th = t * t2 - t1;
216 t1 = t2;
217 t2 = th;
218 th = 8.0E+00 * s1 + t * p2 - p1;
219 p1 = p2;
220 p2 = th;
221 gvec(i-1) = s2;
222 h(j-1,j-1) = h(j-1,j-1) + fvec(i-1) * th + d1 * s2*s2;
223 }

Callers 1

Calls 4

chebyquad_residualsFunction · 0.85
xFunction · 0.85
make_symmetricFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected