Direct calculation of derivative with same number of floating point operations as for f_eval.
| 817 | // Direct calculation of derivative with same number of floating point |
| 818 | // operations as for f_eval. |
| 819 | double df_direct(double x) |
| 820 | { double sum = 0.; |
| 821 | size_t i; |
| 822 | for(i = 0; i < num_sum_; i++) |
| 823 | sum += cos(x); |
| 824 | |
| 825 | return sum / double(num_sum_); |
| 826 | } |
| 827 | |
| 828 | // AD calculation of detivative |
| 829 | void fun_ad(double x, double& f, double& df) |