00001 /* -*- mode:c++ -*- */ 00002 00016 // class FunctionHelper; 00017 00018 class FunctionBase 00019 { 00020 %TypeHeaderCode 00021 #include "functions/FunctionBase.h" 00022 %End 00023 00024 protected: 00025 00026 FunctionBase (); 00027 FunctionBase ( const FunctionBase & ); 00028 virtual double derivByParm ( int , double ) const = 0; 00029 void setName ( const char * ); 00030 virtual void initialize () = 0; 00031 00032 public: 00033 00034 virtual ~FunctionBase(); 00035 00037 const std::string & name () const; 00038 00049 virtual FunctionBase * clone () const; 00050 %VirtualCatcherCode 00051 PyObject *sipResObj = sipCallMethod ( 0, sipMethod, "" ); 00052 if ( !sipResObj || 00053 sipParseResult ( 0, 00054 sipMethod, 00055 sipResObj, 00056 "L", 00057 sipForceConvertTo_FunctionBase, 00058 &sipRes) < 0) { 00059 PyErr_Print(); 00060 } 00061 sipTransfer ( sipResObj, 1 ); 00062 %End 00063 00065 virtual int size () const; 00066 00067 // /** Returns the number of free parameters. 00068 // */ 00069 // virtual unsigned int numberFreeParms () const; 00070 00072 virtual const std::vector < std::string > & parmNames ( ); 00073 00076 void setParmNames ( const std::vector < std::string > & ); 00077 00078 // /** Returns a vector of free parameter names. Names are appended 00079 // at the back of the vector.*/ 00080 // void freeParmNames ( std::vector< std::string > & ) const; 00081 00085 virtual bool isComposite () const; 00086 00090 virtual void addToComposite ( FunctionBase * ); 00091 00095 virtual void removeFromComposite ( FunctionBase * ); 00096 00100 virtual int count (); 00101 00105 virtual const std::vector< double > & getParameters (); 00106 00111 virtual void setParameters ( const std::vector< double > & ); 00112 00113 // /** Returns the fixed parameter flags. */ 00114 // virtual const std::vector < bool > & fixedFlags () const; 00115 00116 // /** Sets the fixed flag for each function parameter. A fixed 00117 // parameter is not returned or set by the values() or setValues() 00118 // member functions. */ 00119 // virtual void setFixedFlags ( const std::vector < bool > & ); 00120 00121 // /** Sets the parameter values to the value pointed to by the 00122 // iterator. Returns an iterator to a data element one past the 00123 // last used data element. */ 00124 // virtual std::vector< double >::const_iterator 00125 // setParameters ( std::vector< double >::const_iterator it ); 00126 00127 // /** Sets the fixed flag for the parameter values. Returns an 00128 // iterator to the end of the sequence used. */ 00129 // virtual std::vector < bool >:: const_iterator 00130 // setFixedFlags ( std::vector < bool >:: const_iterator it ); 00131 00133 virtual double operator () ( double ) const = 0; 00134 00135 // %MethodCode 00136 // sipRes = sipCpp -> operator () ( 0. ); 00137 // %End 00138 00139 00140 // virtual double __call__ ( double ); 00141 // /** The function call operator. @bug Temporary fix until we 00142 // undertand how to get SIP to accept operator()().*/ 00143 // virtual double valueAt ( double ) const; 00144 00145 // /** The function call operator for multi-dimension coordinate 00146 // variable. Returns the value of the function at coordinate 00147 // represented by @a v. The implementation in this base class uses 00148 // the first element of the vector and calls operator () ( double ). 00149 // */ 00150 // virtual double operator () ( const std::vector < double > & v ) const; 00151 00152 // /** Sets the FunctionHelper so that the function can calculate a 00153 // reasonable set of initial parameter values. */ 00154 // virtual void initialParameters ( const FunctionHelper * ); 00155 00156 // /** Returns the value of the free parameters. For each free 00157 // parameter, its value is push_back to the @p parms vector */ 00158 // virtual void getFreeParameters ( std::vector < double > & ) const; 00159 00160 // /** Returns the value of the k-th free parameters. */ 00161 // virtual double getFreeParameter( unsigned int ) const; 00162 00163 // /** Sets the values of the free parameters. */ 00164 // void setFreeParameters ( const std::vector< double > & ); 00165 00166 // /** Sets the values of the free parameters. For each free 00167 // parameter, its value is set from the value pointed by the 00168 // iterator, and the iterator is advanced. Returns the advanced 00169 // iterator. */ 00170 // virtual std::vector< double >:: const_iterator 00171 // setFreeParameters ( std::vector< double >:: const_iterator it ); 00172 00180 virtual bool hasDerivatives () const; 00181 00182 // /** Returns the function's derivatives. Calculates the function's 00183 // derivatives for each free parameter at the coordinate value @p 00184 // x. Appends the derivatives at the end of the sequence @a 00185 // derives. */ 00186 // virtual void getFreeDerivatives ( std::vector < double > & , 00187 // double ) const; 00188 00193 virtual double integrate ( double , double ) const; 00194 00195 };