Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsPolatorAndPsNumericType.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license
00016  *
00017  */
00018 #ifndef PsPolatorAndPsNumericTypeHEADER
00019 #define PsPolatorAndPsNumericTypeHEADER
00020 
00021 #include <PsPolatorNT.h>
00022 #include <iostream>
00023 #include <PsFlowable.h>
00024 #include <PsType.h>
00025 
00026 #include "PsEmptyFifoException.h"
00027 
00031 class PsNumericType : public PsType {
00032 
00033 public :
00035    virtual ~PsNumericType (void) {} ;
00036    
00038    virtual double getValue (void) const = 0 ;
00039 
00040 
00048    static double linearInterpolate(const long t,
00049                                    const long t1, 
00050                                    const double v1,
00051                                    const long t0,
00052                                    const double v0
00053                                    );
00054 
00055 
00065    static double quadraticInterpolate(const long t,
00066                                       const long t2, 
00067                                       const double v2,
00068                                       const long t1, 
00069                                       const double v1,
00070                                       const long t0,
00071                                       const double v0
00072                                       );
00073 
00074 
00075 
00087    static double cubicInterpolate(const long t,
00088                                   const long t3, 
00089                                   const double v3,
00090                                   const long t2, 
00091                                   const double v2,
00092                                   const long t1, 
00093                                   const double v1,
00094                                   const long t0,
00095                                   const double v0
00096                                   );
00097 
00098 
00107    static double linearExtrapolate(const long t,
00108                                    const long t1, 
00109                                    const double v1,
00110                                    const long t0,
00111                                    const double v0
00112                                    );
00113 
00114 
00125    static double quadraticExtrapolate(const long t3,
00126                                       const long t2,
00127                                       const double v2,
00128                                       const long t1,
00129                                       const double v1,
00130                                       const long t0,
00131                                       const double v0);
00132 
00133 
00146    static double cubicExtrapolate(const long t4,
00147                                   const long t3,
00148                                   const double v3,
00149                                   const long t2,
00150                                   const double v2,
00151                                   const long t1,
00152                                   const double v1,
00153                                   const long t0,
00154                                   const double v0);
00155 } ;
00156 
00157 
00158 
00159 //------------------------------------------------------------------
00160 
00161 template <class Type>
00162 
00166 class PsNumericTypeT : public PsNumericType {
00167   
00168 public :
00169   
00171    PsNumericTypeT (void) ;
00172    
00174    PsNumericTypeT (const int) ;
00175 
00177    PsNumericTypeT (const long) ;
00178 
00180    PsNumericTypeT (const float) ;
00181 
00183    PsNumericTypeT (const double) ;
00184    
00186    PsNumericTypeT (const PsNumericTypeT<Type> &) ;
00187    
00189    virtual ~PsNumericTypeT (void) ;
00190 
00191   
00193    virtual PsNumericTypeT & operator ++ (void) ;
00194 
00196    virtual PsNumericTypeT operator ++ (int) ;
00197 
00199    virtual PsNumericTypeT & operator -- (void) ;
00200 
00202    virtual PsNumericTypeT operator -- (int) ;
00203   
00205    virtual PsNumericTypeT & operator = (const PsNumericTypeT <Type> &) ;
00206 
00208    virtual PsNumericTypeT & operator = (int) ;
00209    
00211    virtual PsNumericTypeT & operator = (long int) ;
00212 
00214    virtual PsNumericTypeT & operator = (float) ;
00215    
00217    virtual PsNumericTypeT & operator = (double) ;
00218 
00220    virtual operator Type () const;
00221    
00223    virtual double getValue (void) const ;
00224 
00225 
00227    virtual void insertInStream (ostream & = cout) const ;
00228 
00230    virtual void extract (istream & = cin) ;
00231 
00233    virtual void unpack (PsIncomingSynchronisationMessage &) ;
00234    
00236    virtual void pack (PsOutgoingSynchronisationMessage &) const ;
00237 
00239    virtual PsPolatorNT * createPolator(void)  ;
00240    
00241 private :
00243   Type _data ;
00244 
00245 } ;
00246 
00251 typedef PsNumericTypeT <int> PsInt ;
00252 
00254 typedef PsNumericTypeT <long int> PsLongInt ;
00255 
00257 typedef PsNumericTypeT <float> PsFloat ;
00258 
00260 typedef PsNumericTypeT <double> PsDouble ;
00261 
00263 typedef PsInt PsFrequency ;
00264 
00266 typedef PsLongInt PsDate ;
00268 
00269 
00270 template <typename Type> class PsnAbstractFifo;
00271 
00275 template <typename Type>
00276 class PsPolator : public PsPolatorNT {
00277    
00278 public:
00281    PsPolator(PsnAbstractFifo<Type> *);
00282 
00285    PsPolator(void) ;
00286 
00289    PsPolator(int numberOfValuesForMaxPrecision ) ;
00290 
00293    virtual ~PsPolator(void) ;
00294 
00301    const Type & polate(const int requestedPrecisionLevel,
00302                        const PsDate & t,
00303                        int & distance,
00304                        Type & resultPlaceHolder ) const ;
00305 
00315    virtual const Type & interpolate(Type & resultPlaceHolder,
00316                                     const int interpolateLevel,
00317                                     const PsDate & dateNeeded,
00318                                     const PsDate & dateAfter,
00319                                     const Type & valueAfter,
00320                                     const PsDate & dateBefore,
00321                                     int offsetToMostRecentOfDateBefore
00322                                     ) const ;
00328    virtual const Type & extrapolate(Type & resultPlaceHolder,
00329                                     const int requestedPrecisionLevel,
00330                                     const PsDate & t,
00331                                     const PsDate & tIndice
00332                                     ) const ;
00338    virtual const Type & antepolate(Type & resultPlaceHolder,
00339                                      const int requestedPrecisionLevel,
00340                                      const PsDate & t,
00341                                      const PsDate & tIndice,
00342                                      unsigned int indice 
00343                                      ) const ;
00346    void setFifo(PsnAbstractFifo<Type> * fifo) ; 
00347    
00349 protected:
00350   // on delivre une valeur par rapport a une date
00351   // si la date est anterieure, c'est la valeur associe dans la file
00352   // si la date est dans le futur le resultat est la derniere valeur de la file
00353   //
00354     // ce sont des appels aux methode de la file
00355   // transparent a l'utilisateur
00356   //-----------------------------------------------
00359    int getNumberOfPresentValues (int maxNeeded = -1) const   ; // nbre de valeur dans la file
00360   
00367   const Type & get(const int indice) const  ;
00371    const PsDate & getDate(const int indice) const  ;
00372  
00373 protected:
00376    PsnAbstractFifo<Type> * _fifo ; 
00377 
00378 private:
00381    void intialisePolator() ;
00382 
00383 } ;
00384 
00385 #include <PsnAbstractFifo.h>
00386 #include "PsIncomingSynchronisationMessage.h"
00387 #include "PsOutgoingSynchronisationMessage.h"
00388 
00389 template <typename Type>
00390 
00391 PsNumericTypeT<Type>::PsNumericTypeT (void) {
00392 
00393 _data = 0 ;
00394 }
00395 
00396 //------------------------------------------------------------------
00397 
00398 template <typename Type>
00399 
00400 PsNumericTypeT<Type>::PsNumericTypeT (const int d) {
00401   _data = Type (d) ;
00402   //_data = (Type)d ;
00403 }
00404 
00405 //------------------------------------------------------------------
00406 
00407 template <typename Type>
00408 
00409 PsNumericTypeT<Type>::PsNumericTypeT (const long d) {
00410   _data = Type (d) ;
00411   //_data = (Type)d ;
00412 }
00413 
00414 //------------------------------------------------------------------
00415 
00416 template <typename Type>
00417 
00418 PsNumericTypeT<Type>::PsNumericTypeT (const float d) {
00419   _data = Type (d) ;
00420   //_data = (Type)d ;
00421 }
00422 
00423 //------------------------------------------------------------------
00424 
00425 template <typename Type>
00426 
00427 PsNumericTypeT<Type>::PsNumericTypeT (const double d) {
00428   _data = Type (d) ;
00429   //_data = (Type)d ;
00430 }
00431 
00432 //------------------------------------------------------------------
00433 
00434 template <typename Type>
00435 
00436 PsNumericTypeT<Type>::PsNumericTypeT (const PsNumericTypeT<Type> & t) {
00437   //_data = (Type)t.getValue () ;
00438   _data = t._data ;
00439 }
00440 
00441 
00442 //------------------------------------------------------------------
00443 
00444 template <typename Type>
00445 
00446 PsNumericTypeT<Type>::~PsNumericTypeT (void) {
00447 
00448 }
00449 
00450 //------------------------------------------------------------------
00451 
00452 template <typename Type>
00453 void PsNumericTypeT<Type>::pack (PsOutgoingSynchronisationMessage & out) const
00454 {
00455   out<<_data ;
00456 }
00457 
00458 template <typename Type>
00459 void PsNumericTypeT<Type>::unpack (PsIncomingSynchronisationMessage & in)
00460 {
00461   in>>_data ;
00462 }
00463 
00464 template <typename Type>
00465 void PsNumericTypeT<Type>::insertInStream (ostream & out) const {
00466    out << _data ;
00467 }
00468 
00469 //------------------------------------------------------------------
00470 
00471 template <typename Type>
00472 
00473  void PsNumericTypeT<Type>::extract (istream & in) {
00474   in >> _data ;
00475 }
00476 
00477 
00478 
00479 //------------------------------------------------------------------
00480 #include <PsNumericPolator.h>
00481 
00482 template <typename Type>
00483 
00484 PsPolatorNT * PsNumericTypeT<Type>::createPolator(void)
00485 {
00486   // C'est l'utilisateur qui doit desaloue l'interpolateur cree
00487    //DM : non c'est le destructeur de PsnTypeT qui s'en charge
00488   PsNumericPolatorT <Type> * interp ; 
00489   interp = new PsNumericPolatorT<Type>();
00490   return ((PsPolatorNT *)interp) ;
00491 } 
00492 
00493 
00494 //------------------------------------------------------------------
00495 
00496 template <typename Type>
00497 
00498 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator ++ (void) {
00499   ++ _data ;
00500   return *this ;
00501 }
00502 
00503 //------------------------------------------------------------------
00504 
00505 template <typename Type>
00506 
00507 PsNumericTypeT<Type> PsNumericTypeT<Type>::operator ++ (int) {
00508   PsNumericTypeT<Type> retour (*this) ;
00509   ++ (* this) ;
00510   return retour ;
00511 }
00512 
00513 //------------------------------------------------------------------
00514 
00515 template <typename Type>
00516 
00517 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator -- (void) {
00518   -- _data ;
00519   return *this ;
00520 }
00521 
00522 //------------------------------------------------------------------
00523 
00524 template <typename Type>
00525 
00526 PsNumericTypeT<Type> PsNumericTypeT<Type>::operator -- (int) {
00527   PsNumericTypeT<Type> retour (*this) ;
00528   -- (* this) ;
00529   return retour ;
00530 }
00531 
00532 //------------------------------------------------------------------
00533 
00534 template <typename Type>
00535 
00536 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator = (const PsNumericTypeT<Type> & n) {
00537   //  cout << "**************NUMERIQUE****************" << endl ;
00538   // cout << " operateur = " << endl ;
00539   if (this != &n) {
00540     //    _data = n.getValue () ;
00541     _data = n._data ;
00542   }
00543   return *this ;
00544 }
00545 
00546 //------------------------------------------------------------------
00547 
00548 template <typename Type>
00549 
00550 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator = (int n) {
00551   _data = Type (n) ;
00552   //_data = (Type)n ;
00553   return *this ;
00554 }
00555 
00556 //------------------------------------------------------------------
00557 
00558 template <typename Type>
00559 
00560 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator = (long int n) {
00561   _data = Type (n) ;
00562   //_data = (Type)n ;
00563   return *this ;
00564 }
00565 
00566 //------------------------------------------------------------------
00567 
00568 template <typename Type>
00569 
00570 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator = (float n) {
00571   _data = Type (n) ;
00572   //_data = (Type)n ;
00573   return *this ;
00574 }
00575 
00576 //------------------------------------------------------------------
00577 
00578 template <typename Type>
00579 
00580 PsNumericTypeT<Type> & PsNumericTypeT<Type>::operator = (double n) {
00581   _data = Type (n) ;
00582   //_data = (Type)n ;
00583   return *this ;
00584 }
00585 
00586 
00587 //------------------------------------------------------------------
00588 
00589 template <typename Type>
00590 
00591 double PsNumericTypeT<Type>:: getValue() const {
00592   return (double)_data ;
00593 }
00594 
00595 //------------------------------------------------------------------
00596 
00597 template <typename Type>
00598 
00599 PsNumericTypeT<Type>::operator Type  () const {
00600   return _data ;
00601 }
00602 
00603 //------------------------------------------------------------------
00604 
00605 //  template <typename Type>
00606 
00607 //  Type PsNumericTypeT<Type>::getData (void) const {
00608 //    return _data ;
00609 //  }
00610 
00611 //------------------------------------------------------------------
00612 
00613 template <typename Type>
00614 
00615 PsNumericTypeT<Type> operator - (const PsNumericTypeT<Type> & n) {
00616   return  (PsNumericTypeT<Type> (- n.getValue ())) ;
00617 }
00618 
00619 //---------------------------------------------------------------
00620 template <typename Type>
00621 inline PsPolator<Type>::PsPolator() : PsPolatorNT ( 0 )
00622 {
00623 #ifdef _DEBUGTYPEUTIL
00624   cout << "PsPolator constructeur sans file" << endl;
00625 #endif
00626   intialisePolator();
00627 }
00628 
00629 
00630 //---------------------------------------------------------------
00631 template <typename Type>
00632 inline PsPolator<Type>::PsPolator(int numberOfValuesForMaxPrecision) : PsPolatorNT ( numberOfValuesForMaxPrecision )
00633 {
00634 #ifdef _DEBUGTYPEUTIL
00635   cout << "PsPolator constructeur avec paramètre et sans file" << endl;
00636 #endif
00637   intialisePolator();
00638 }
00639 
00640 //---------------------------------------------------------------
00641 template <typename Type>
00642 inline PsPolator<Type>::PsPolator(PsnAbstractFifo<Type> * file2) : PsPolatorNT ( 0 )
00643 {
00644 #ifdef _DEBUGTYPEUTIL
00645   cout << "PsPolator constructeur avec file" << endl;
00646 #endif
00647  
00648   intialisePolator();
00649   _fifo = file2 ; 
00650 }
00651 
00652 template  <typename Type>
00653 inline void PsPolator<Type>::intialisePolator() {
00654   _fifo = NULL ;
00655 }
00656 
00657 //---------------------------------------------------------------
00658 template <typename Type>
00659 inline PsPolator<Type>::~PsPolator()
00660 {
00661 }
00662 //---------------------------------------------------------------
00663 template <typename Type>
00664 inline const Type & PsPolator<Type>::get(const int value) const
00665 {
00666   return _fifo->getPreceedingValue(value) ;
00667 }
00668 
00669 //---------------------------------------------------------------
00670 template <typename Type>
00671 inline const PsDate & PsPolator<Type>::getDate(const int value) const
00672 {
00673 #ifdef _DEBUGTYPEUTIL
00674    cerr<<"PsPolator<Type>::"<<this<<"::getDate ("<<value<<") "<<endl;
00675 #endif
00676   return _fifo->getPreceedingDate(value) ;
00677 }
00678 
00679 
00680 //---------------------------------------------------------------
00681 
00682 template <typename Type>
00683 inline void PsPolator<Type>::setFifo(PsnAbstractFifo<Type> * fifo)
00684 {
00685 #ifdef _DEBUGTYPEUTIL
00686    cerr<<"PsPolator<Type>::setFifo "<<endl;
00687 #endif
00688   _fifo = fifo ; 
00689 }
00690 
00691 //---------------------------------------------------------------
00692 template <typename Type>
00693 inline int PsPolator<Type>::getNumberOfPresentValues (int maxNeeded ) const 
00694 {
00695 #ifdef _DEBUGTYPEUTIL
00696    cerr<<"PsPolator<Type>::getNumberOfPresentValues"<<endl;
00697 #endif
00698   return(_fifo->getNumberOfPresentValues(maxNeeded));
00699 }
00700 //---------------------------------------------------------------
00701 template <typename Type>
00702 const Type & PsPolator<Type>::polate(
00703                                      const int requestedPrecisionLevel,
00704                                      const PsDate & t,
00705                                      int & distanceTemporelle,
00706                                      Type & resultPlaceHolder
00707                                      ) const 
00708 {
00709 #ifdef _DEBUGTYPEUTIL
00710    cerr<<"PsPolator<Type>::"<<this<<"::polate ("<<requestedPrecisionLevel<<","<<t<<") "<<endl;
00711 #endif
00712 
00713 
00714   int requestedPrecisionLevelPossible = requestedPrecisionLevel ;
00715   //_fifo->initialiseContext() ;
00716   int NumberOfPresentValues = getNumberOfPresentValues(requestedPrecisionLevel+1) ;
00717   
00718 #ifdef _DEBUGTYPEUTIL
00719   cerr<<"PsPolator<Type>::"<<this<<"::polate : NumberOfPresentValues : "<<NumberOfPresentValues<<endl;
00720 #endif
00721 
00722   if (NumberOfPresentValues==0) { 
00723      throw PsEmptyFifoException ("PsPolator::polate") ;
00724   }
00725 
00726   // Same test for antepolate and extrapolate
00727   // ------------------------------------------------
00728   if (NumberOfPresentValues<=requestedPrecisionLevel) {
00729 
00730      requestedPrecisionLevelPossible = NumberOfPresentValues-1;
00731      
00732   }
00733 
00734   const PsDate & dateDerniereValeur( getDate( 0 ) );
00735   
00736   assert(dateDerniereValeur != -1) ;
00737 
00738   if (dateDerniereValeur <t)
00739     {                         
00740 #ifdef _DEBUGTYPEUTIL
00741        cerr<<"Cas de l'extrapolation"<<endl;
00742 #endif
00743        
00744        distanceTemporelle = t - dateDerniereValeur ;
00745        
00746       
00747       // On est dans le cas d'une extrapolation
00748        assert (t != dateDerniereValeur) ;
00749        assert ((NumberOfPresentValues != 1)||(requestedPrecisionLevelPossible == 0)) ;
00750        return extrapolate(resultPlaceHolder, 
00751                           requestedPrecisionLevelPossible, 
00752                           t, 
00753                           dateDerniereValeur );
00754     }
00755 
00756   // On est dans la configuration suivante :
00757   // t <= DateDerniereValeurs 
00758   //               ***********
00759   // - Soit on recupere une date dans la file qui correspond a t
00760   // - Soit on interpole
00761   // - soit on antépole
00762 
00763 
00764 
00765   int indice = 0 ; // l'indice le plus proche dans la file correspondant a la date t
00766 
00767   unsigned int numberOfValuesInFifoNeededToContinueExamination = 2 ;
00768 
00769   PsDate const * examinedDate = & dateDerniereValeur ;
00770   PsDate const * dateExaminedBefore = NULL ;
00771   Type const * valueExaminedBefore = NULL ; 
00772 
00773   bool pasTrouve ;  // end of iteration
00774   bool exact ;    // interpolation needed
00775   
00776   if (*examinedDate == t) 
00777     {
00778       pasTrouve = false ;
00779       exact = true ;
00780     }
00781   else 
00782     {
00783       pasTrouve = true ;
00784       exact = false ;     
00785     }
00786 #ifdef _DEBUGTYPEUTIL
00787   cerr <<"PsPolator<Type>::polate : Boucle de recherche de valeurs...."<<t<< endl ;
00788 #endif
00789 
00790   while ( (pasTrouve) &&
00791           (_fifo->getNumberOfPresentValues(numberOfValuesInFifoNeededToContinueExamination) >= numberOfValuesInFifoNeededToContinueExamination  ) ) 
00792      {
00793         
00794 #ifdef _DEBUGTYPEUTIL
00795         cerr<<"variables de boucles : "
00796             <<pasTrouve<<" "
00797             <<examinedDate<<" "
00798             <<exact<<" "
00799             <<t<<" "
00800             <<indice<<" "
00801             <<numberOfValuesInFifoNeededToContinueExamination<<endl;
00802 #endif
00803 
00804         dateExaminedBefore = examinedDate ;
00805         valueExaminedBefore = & get (indice) ;
00806         indice ++ ;
00807         examinedDate = & getDate ( indice ) ;
00808 
00809         if ( *examinedDate == t ) {
00810            
00811            pasTrouve = false ;
00812            exact = true ;
00813            
00814         }
00815         else if ( *examinedDate < t )
00816            {
00817               
00818               pasTrouve = false ;
00819               exact = false ;
00820            }
00821 
00822         ++numberOfValuesInFifoNeededToContinueExamination ;
00823 
00824 #ifdef _DEBUGATTRIBUTSMOME
00825         if (indice > 4) cerr<<"On demande loin "<<NumberOfPresentValues<<" "<<examinedDate<<" "<<t<<endl;
00826 #endif
00827      }
00828   
00829   if (*examinedDate > t) {//because of relaxed coherance, this can sometimes happen
00830     return  antepolate(resultPlaceHolder, 
00831                        requestedPrecisionLevelPossible, 
00832                        t, 
00833                        *examinedDate, 
00834                        indice );
00835   }
00836 
00837   /* here, dateOfOldestValueAvailable <= examinedDate <= t <= oldExaminedDate <= dateDerniereValeur, with examinedDate == t if exact */
00838 
00839   distanceTemporelle = t - *examinedDate ;
00840   if ( ! exact) {
00841     assert ( dateExaminedBefore != NULL) ;
00842     assert ( valueExaminedBefore != NULL ) ;
00843      return  interpolate ( resultPlaceHolder,
00844                              requestedPrecisionLevelPossible, 
00845                              t, 
00846                              *dateExaminedBefore, 
00847                              *valueExaminedBefore,
00848                              *examinedDate, 
00849                              indice) ;
00850   }  
00851   else {
00852      return  get( indice ) ;
00853   }
00854 }
00855 
00856 //---------------------------------------------------------------
00857 //   t -> date a laquelle on veut trouver un valeur
00858 //   tIndice -> date de l'indice avec lequel on va pouvoir trouver
00859 //              une nouvelle valeur
00860 //
00861 //   
00862 //                       -tIndice selon lineaire , PsPolatorNT::Quadratic ,etc  
00863 //           l   q  c
00864 //       ------------- 
00865 //       |t |tI|tI|tI|
00866 //       -------------
00867 //
00868 //
00869 //   t < tIndice
00870 //
00871 //--------------------------------------------------------------
00872 template <typename Type>
00873 inline const Type & PsPolator<Type>::interpolate (Type & resultPlaceHolder,
00874                                                   const int interprecisionLevel,
00875                                                   const PsDate & dateNeeded,
00876                                                   const PsDate & dateAfter,
00877                                                   const Type & valueAfter,
00878                                                   const PsDate & dateBefore,
00879                                                   int offsetToMostRecentOfDateBefore
00880                                                   ) const 
00881 {
00882    
00883 #ifdef _DEBUGTYPEUTIL
00884    cout << "*********************************************" << endl ;
00885    cout << "PsPolator::interpolation PAR DEFAUT" << endl;
00886    cout << "PsDate dateAfter <----- : " << dateAfter << endl ;
00887    cout << "PsDate dateNeeded <----- : " << dateNeeded << endl ;
00888    cout << "PsDate dateBefore <----- : " << dateBefore << endl ;
00889    cout << "Type : valueAfter " << valueAfter << endl ;
00890    cout << "int : offsetToMostRecentOfDateBefore " << offsetToMostRecentOfDateBefore << endl ;
00891 #endif
00892    
00893   if ( (dateAfter - dateNeeded) <= (dateNeeded - dateBefore) ) 
00894      {
00895         resultPlaceHolder = valueAfter ;
00896      }
00897   else 
00898      {
00899         resultPlaceHolder = get (offsetToMostRecentOfDateBefore) ;
00900      }
00901 
00902   return resultPlaceHolder ; 
00903 
00904 }
00905 
00906 //---------------------------------------------------------------
00907 
00908 
00909 template <typename Type>
00910 inline const Type & PsPolator<Type>::extrapolate(Type & resultPlaceHolder,
00911                                                  const int requestedPrecisionLevel,
00912                                                  const PsDate & t,
00913                                                  const PsDate & tIndice
00914                                                  ) const
00915                                         
00916 {
00917 #ifdef _DEBUGTYPEUTIL
00918   cout << "*********************************************" << endl ;
00919   cout << "PsPolator<Type>::extrapolate PAR DEFAUT" << endl;
00920   cout << "PsDate t <----- : " << t << endl ;
00921   cout << "PsDate tIndice <----- : " << tIndice << endl ;
00922   cout << "niveau interpolation : " << requestedPrecisionLevel << endl ;
00923   cout << "indice dernier: " << requestedPrecisionLevel << endl ;
00924   cout << "*********************************************" << endl ;
00925 #endif
00926   
00927   return get(0); 
00928   
00929 }
00930 //---------------------------------------------------------------
00931 template <typename Type>
00932 inline const Type & PsPolator<Type>::antepolate(Type & resultPlaceHolder,
00933                                                 const int requestedPrecisionLevel,
00934                                                 const PsDate & t,
00935                                                 const PsDate & tIndice,
00936                                                 unsigned int indice
00937                                                 ) const
00938    
00939 {
00940 #ifdef _DEBUGTYPEUTIL
00941   cout << "*********************************************" << endl ;
00942   cout << "PsPolator::antepolate" << endl;
00943   cout << "PsDate t <----- : " << t << endl ;
00944   cout << "PsDate tIndice <----- : " << tIndice << endl ;
00945   cout << "niveau interpolate : " << requestedPrecisionLevel << endl ;
00946   cout << "indice dernier: " << indice << endl ;
00947   cout << "*********************************************" << endl ;
00948 #endif
00949   
00950   return get(indice); 
00951   
00952 }
00953 
00954 #endif

logo OpenMask

Documentation generated on Mon Nov 25 15:25:02 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001