36 #include "gsl/gsl_deriv.h"
47 double GSLDerivator::EvalCentral(
double x,
double h) {
49 if ( !fFunction.IsValid() ) {
50 std::cerr <<
"GSLDerivator: Error : The function has not been specified" << std::endl;
54 fStatus = gsl_deriv_central( fFunction.GetFunc(), x, h, &fResult, &fError);
58 double GSLDerivator::EvalForward(
double x,
double h) {
60 if ( !fFunction.IsValid() ) {
61 std::cerr <<
"GSLDerivator: Error : The function has not been specified" << std::endl;
65 fStatus = gsl_deriv_forward( fFunction.GetFunc(), x, h, &fResult, &fError);
69 double GSLDerivator::EvalBackward(
double x,
double h) {
71 if ( !fFunction.IsValid() ) {
72 std::cerr <<
"GSLDerivator: Error : The function has not been specified" << std::endl;
76 fStatus = gsl_deriv_backward( fFunction.GetFunc(), x, h, &fResult, &fError);
81 double GSLDerivator::EvalCentral(
const IGenFunction & f,
double x,
double h) {
83 GSLFunctionWrapper gslfw;
84 double result, error = 0;
86 gsl_deriv_central( gslfw.GetFunc(), x, h, &result, &error);
90 double GSLDerivator::EvalForward(
const IGenFunction & f,
double x,
double h) {
92 GSLFunctionWrapper gslfw;
93 double result, error = 0;
95 gsl_deriv_forward( gslfw.GetFunc(), x, h, &result, &error);
99 double GSLDerivator::EvalBackward(
const IGenFunction & f,
double x,
double h) {
101 GSLFunctionWrapper gslfw;
102 double result, error = 0;
103 gslfw.SetFunction(f);
104 gsl_deriv_backward( gslfw.GetFunc(), x, h, &result, &error);
109 double GSLDerivator::Result()
const {
return fResult; }
111 double GSLDerivator::Error()
const {
return fError; }
113 int GSLDerivator::Status()
const {
return fStatus; }
117 void GSLDerivator::SetFunction( GSLFuncPointer fp,
void * p) {
118 fFunction.SetFuncPointer( fp );
119 fFunction.SetParams ( p );
123 void GSLDerivator::SetFunction(
const IGenFunction &f) {
124 fFunction.SetFunction(f);