OptIntp.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  $RCSfile: OptIntp.h,v $ --- $Date: 2006/07/19 13:21:43 $ --- $Revision: 1.3 $
00003  *****************************************************************************
00004  PREPROCESSOR DIRECTIVES
00005  *****************************************************************************/
00006 
00007  #ifndef CALC_OPTINTP_H
00008  #define CALC_OPTINTP_H
00009 
00010 /*****************************************************************************
00011  INCLUDE FILES
00012  *****************************************************************************/
00013 
00014  #include <cstdlib>
00015  #include <iomanip>
00016 
00017  #include "Base.h"
00018  #include "NIntp.h"
00019 
00020 /*****************************************************************************
00021  NAMESPACE IDENTIFICATIONS
00022  *****************************************************************************/
00023 
00024  namespace calc {
00025 
00026 /*****************************************************************************
00027  OptIntp CLASS TEMPLATE
00028  *****************************************************************************/
00034 
00035 
00105  template <typename xType, typename yType>
00106  class OptIntp:public Base {
00107 
00108  public:
00109 
00110  // Enumerations
00111 
00113     enum VTYPE {
00114        GRID_AVG=0,    
00115        GRID_DEV,      
00116        GRID_MAX,      
00117        RANDOM_AVG,    
00118        RANDOM_DEV,    
00119        RANDOM_MAX,    
00120        VTYPE_CNT,     
00121     };
00122 
00124     enum PTYPE {
00125        GRID_SAMPLE=0,    
00126        RANDOM_COUNT,     
00127        RANDOM_SEED,      
00128        LOOP_MAXIMUM,     
00129        PTYPE_CNT,        
00130     };
00131 
00132  // Constructors
00133 
00134     OptIntp(yType (&rFn)(const xType*), NIntp<xType,yType> &ni);
00135     OptIntp(const OptIntp<xType,yType> &ei);
00136    ~OptIntp(void);
00137 
00138  // Member Functions
00139 
00140     yType   evalBasis      (const xType *vXn) const throw (IntpErr);
00141     yType   evalTable      (const xType *vXn) throw (IntpErr);
00142     bool    gridError      (xType **yErr=(xType**)(0));
00143     bool    randomError    (void);
00144     bool    update         (const xType *const *arXn=(xType**)(0), const yType *arYn=(yType*)(0));
00145     bool    setBasis       (yType (&rFn)(const xType*));
00146     bool    setParameter   (enum OptIntp<xType,yType>::PTYPE pType, int param);
00147     bool    setPrintStatus (bool flag);
00148 
00149     bool    optimize       (xType xTol, xType yTol);
00150     bool    optimize       (const xType *xTol, xType yTol);
00151 
00166     xType getError(enum OptIntp<xType,yType>::VTYPE vType) const
00167       {return ((vType>=0)&&(vType<VTYPE_CNT)?yErrVal[vType]:(xType)(-1));}
00203     int getParameter(enum OptIntp<xType,yType>::PTYPE pType) const
00204       {return ((pType>=0)&&(pType<PTYPE_CNT)?errParam[pType]:-1);}
00215     NIntp<xType,yType> *getNIntp(void) {return np;}
00222     yType (*getBasis(void))(const xType*) {return pFn;}
00239     bool getPrintStatus(void) const {return bPrg;}
00240 
00241     template <typename bType>
00242     static bool setSpanX (bType **arXn, bType vXLo, bType vXHi,
00243                    const int *arNn, int nDimen);
00244     template <typename bType>
00245     static bool setSpanX (bType **arXn, const bType *arXLo, const bType *arXHi,
00246                    const int *arNn, int nDimen);
00247 
00248     static const int DEF_GRID_SAMPLE;
00249     static const int DEF_RANDOM_COUNT;
00250     static const int DEF_RANDOM_SEED;
00251     static const int DEF_LOOP_MAX;
00252 
00253  private:
00254 
00255  // Member Functions
00256 
00257     static xType optIntvl (xType x, xType xEps);
00258 
00259     virtual void varInit (void);
00260 
00261     bool   varAlloc   (int nDimen);
00262     xType  errorPoint (void) throw (IntpErr);
00263 
00264     bool   optFactors  (xType **cDat, xType **yErr, xType *avErr, xType yEps);
00265     void   optEvalM1   (const xType *const *pXn, yType *pYn, int iDat, int iDim);
00266     void   optCopyM1   (const yType *aYn, yType *pYn, int iDat, int iDim);
00267 
00282     int iLocateX(int iDimen, int iDataY) const
00283        {return (iDataY/nItv[iDimen])%np->getArrayN(np->DIMENSION)[iDimen];}
00298     int iLocateDY(int iDimen, int iDataX) const {return iDataX*nItv[iDimen];}
00299 
00300  // Data Members
00301 
00302     yType   (*pFn)(const xType*);       
00303     NIntp<xType,yType>  *np;            
00304     xType    xTstCnt;                   
00305     xType    xVolSum;                   
00306     xType    yErrVal[VTYPE_CNT];        
00307     xType   *xVol;                      
00308     xType   *frac[Base::BOUND_CNT];     
00309     xType  **xTst;                      
00310     xType   *xVec;                      
00311     int     *mItv;                      
00312     int     *nItv;                      
00313     int     *tItv;                      
00314     int     *iVec;                      
00315     int      errParam[PTYPE_CNT];       
00316     int      nDim;                      
00317     int      nTst;                      
00318     int      mCnt;                      
00319     bool     bPrg;                      
00320  };}
00321 
00322 /*****************************************************************************/
00323 
00325  template <typename xType, typename yType>
00326  const int calc::OptIntp<xType,yType>::DEF_GRID_SAMPLE =1;
00328  template <typename xType, typename yType>
00329  const int calc::OptIntp<xType,yType>::DEF_RANDOM_COUNT=2000;
00331  template <typename xType, typename yType>
00332  const int calc::OptIntp<xType,yType>::DEF_RANDOM_SEED =1;
00334  template <typename xType, typename yType>
00335  const int calc::OptIntp<xType,yType>::DEF_LOOP_MAX=1000;
00336 
00337 /*****************************************************************************
00338  PREPROCESSOR DIRECTIVES
00339  *****************************************************************************/
00340 
00341  #endif
00342 
00343 /*****************************************************************************
00344  CLASS TEMPLATE SOURCE
00345  *****************************************************************************/
00346 
00347  #include "OptIntp.cpp"
00348 
00349 /*****************************************************************************/

Generated on Wed Jul 19 09:23:35 2006 for CalcLib by  doxygen 1.4.7