| 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 |
no test coverage detected