// $Id$ // // File: nnann_function_step.h // Created: Thu Apr 7 14:22:02 EDT 2011 // Creator: davidl (on Darwin Amelia.local 9.8.0 i386) // #ifndef _nnann_function_step_ #define _nnann_function_step_ #include #include class nnann_function_step:public nnann_function{ public: nnann_function_step(void){} virtual ~nnann_function_step(){}; std::string GetName(void){return "Step";} virtual double f(double x){ return x>0.5 ? 1.0:0.0; } virtual double dfdx(double x){ double xx = x-0.5; double slope = fabs(xx)<1.0E-3 ? 1.0E3:(1.0/fabs(xx)); return xx>0.0 ? slope:-slope; // derivative of step } double InputError(double x, double target){ double output = f(x); //_DBG_<<"x="<