| 276 | } |
| 277 | |
| 278 | int nsl_diff_third_deriv_second_order(const double* x, double* y, const size_t n) { |
| 279 | if (n < 5) |
| 280 | return -1; |
| 281 | |
| 282 | double dy[5] = {0}, xdata[5], ydata[5]; |
| 283 | size_t i, j; |
| 284 | for (i = 0; i < n; i++) { |
| 285 | if (i == 0) |
| 286 | for (j = 0; j < 5; j++) |
| 287 | xdata[j] = x[j], ydata[j] = y[j]; |
| 288 | else if (i > 2 && i < n - 3) |
| 289 | for (j = 0; j < 5; j++) |
| 290 | xdata[j] = x[i - 2 + j], ydata[j] = y[i - 2 + j]; |
| 291 | |
| 292 | /* 5-point rule */ |
| 293 | dy[0] = nsl_sf_poly_interp_lagrange_4_deriv3(x[i], xdata, ydata); |
| 294 | |
| 295 | if (i == n - 1) |
| 296 | for (j = 0; j < 4; j++) |
| 297 | y[i - j] = dy[j]; |
| 298 | |
| 299 | if (i > 3) |
| 300 | y[i - 4] = dy[4]; |
| 301 | for (j = 4; j > 0; j--) |
| 302 | if (i >= j - 1) |
| 303 | dy[j] = dy[j - 1]; |
| 304 | } |
| 305 | |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | int nsl_diff_fourth_deriv(const double* x, double* y, const size_t n, int order) { |
| 310 | switch (order) { |
no test coverage detected