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

Function chebyquad_residuals

dlib/test/optimization_test_functions.cpp:22–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 // ----------------------------------------------------------------------------------------
21
22 matrix<double,0,1> chebyquad_residuals(const matrix<double,0,1>& x)
23 {
24 matrix<double,0,1> fvec(x.size());
25 const int n = x.size();
26 int i;
27 int j;
28 double t;
29 double t1;
30 double t2;
31 double th;
32 fvec = 0;
33
34 for (j = 1; j <= n; ++j)
35 {
36 t1 = 1.0E+00;
37 t2 = 2.0E+00 * x(j-1) - 1.0E+00;
38 t = 2.0E+00 * t2;
39 for (i = 1; i <= n; ++i)
40 {
41 fvec(i-1) = fvec(i-1) + t2;
42 th = t * t2 - t1;
43 t1 = t2;
44 t2 = th;
45 }
46 }
47
48 for (i = 1; i <= n; ++i)
49 {
50 fvec(i-1) = fvec(i-1) / (double) ( n );
51 if ( ( i%2 ) == 0 )
52 fvec(i-1) = fvec(i-1) + 1.0E+00 / ( (double)i*i - 1.0E+00 );
53 }
54
55 return fvec;
56 }
57
58 // ----------------------------------------------------------------------------------------
59

Callers 4

chebyquad_residualFunction · 0.85
chebyquadFunction · 0.85
chebyquad_derivativeFunction · 0.85
chebyquad_hessianFunction · 0.85

Calls 2

xFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected