| 221 | return integration; |
| 222 | } |
| 223 | double Integrator::ClenshawCurtisQuadrature2(IntegrationFunction& function, void* customData, double start, double end, std::vector<double> series, double epsilon) |
| 224 | { |
| 225 | double integration; |
| 226 | int j, k, l; |
| 227 | double err, esf, eref, erefh, hh, ir, iback, irback, ba, ss, x, y, fx, errir; |
| 228 | int lenw = series.size() - 1; |
| 229 | esf = 10; |
| 230 | ba = 0.5 * (end - start); |
| 231 | ss = 2 * series[lenw]; |
| 232 | x = ba * series[lenw]; |
| 233 | series[0] = 0.5 * (function)(start, customData); |
| 234 | series[3] = 0.5 * (function)(end, customData); |
| 235 | series[2] = (function)(start + x, customData); |
| 236 | series[4] = (function)(end - x, customData); |
| 237 | series[1] = (function)(start + ba, customData); |
| 238 | eref = 0.5 * (fabs(series[0]) + std::fabs(series[1]) + std::fabs(series[2]) + std::fabs(series[3]) + std::fabs(series[4])); |
| 239 | series[0] += series[3]; |
| 240 | series[2] += series[4]; |
| 241 | ir = series[0] + series[1] + series[2]; |
| 242 | integration = series[0] * series[lenw - 1] + series[1] * series[lenw - 2] + series[2] * series[lenw - 3]; |
| 243 | erefh = eref * std::sqrt(epsilon); |
| 244 | eref *= epsilon; |
| 245 | hh = 0.25; |
| 246 | l = 2; |
| 247 | k = lenw - 5; |
| 248 | do { |
| 249 | iback = integration; |
| 250 | irback = ir; |
| 251 | x = ba * series[k + 1]; |
| 252 | y = 0; |
| 253 | integration = series[0] * series[k]; |
| 254 | for (j = 1; j <= l; j++) { |
| 255 | x += y; |
| 256 | y += ss * (ba - x); |
| 257 | fx = (function)(start + x, customData) + (function)(end - x, customData); |
| 258 | ir += fx; |
| 259 | integration += series[j] * series[k - j] + fx * series[k - j - l]; |
| 260 | series[j + l] = fx; |
| 261 | } |
| 262 | ss = 2 * series[k + 1]; |
| 263 | err = esf * l * std::fabs(integration - iback); |
| 264 | hh *= 0.25; |
| 265 | errir = hh * std::fabs(ir - 2 * irback); |
| 266 | l *= 2; |
| 267 | k -= l + 2; |
| 268 | } while ((err > erefh || errir > eref) && k > 4 * l); |
| 269 | integration *= end - start; |
| 270 | if (err > erefh || errir > eref) |
| 271 | { |
| 272 | err *= -fabs(end - start); |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | err = eref * std::fabs(end - start); |
| 277 | } |
| 278 | return integration; |
| 279 | } |
| 280 | } |
nothing calls this directly
no outgoing calls
no test coverage detected