#include <OMKPolator.h>
Inheritance diagram for OMK::Type::Polator< T >:
Public Member Functions | |
Polator (AbstractFifo< T > *) | |
Do not use : constructor with associated history fifo. | |
Polator () | |
Default constructor. | |
Polator (int numberOfValuesForMaxPrecision) | |
Contructor defining the number of values needed for a miximum precision level . | |
virtual | ~Polator () |
Destructor. | |
const T & | polate (const int requestedPrecisionLevel, const Date &t, int &timeDistance, T &resultPlaceHolder) const |
Generic polation member function. | |
virtual const T & | interpolate (T &resultPlaceHolder, const int interpolateLevel, const Date &dateNeeded, const Date &dateAfter, const T &valueAfter, const Date &dateBefore, int offsetToMostRecentOfDateBefore) const |
Interpolation member function. | |
virtual const T & | extrapolate (T &resultPlaceHolder, const int requestedPrecisionLevel, const Date &t, const Date &tIndex) const |
Extrapolation member function. | |
virtual const T & | antepolate (T &resultPlaceHolder, const int requestedPrecisionLevel, const Date &t, const Date &tIndex, unsigned int index) const |
Antepolation member function. | |
void | setFifo (AbstractFifo< T > *fifo) |
update fifo associated with polator | |
Protected Member Functions | |
int | getNumberOfPresentValues (int maxNeeded=-1) const |
const T & | get (const int index) const |
Returns a value of the fifo. | |
const Date & | getDate (const int index) const |
Returns date of a value in the fifo. | |
Protected Attributes | |
AbstractFifo< T > * | _fifo |
Pointer to the fifo with values of an ouput. | |
Private Member Functions | |
void | initialisePolator () |
Initialises the Polator. |
Strictly speeking, objects of this type never do any polations.
Definition at line 37 of file OMKPolator.h.
OMK::Type::Polator< T >::Polator | ( | AbstractFifo< T > * | ) | [inline] |
Do not use : constructor with associated history fifo.
Definition at line 184 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo, OMK::Type::Polator< T >::initialisePolator(), OMK_DEBUG_OMK_POL, and OMTRACEID.
00185 : PolatorNT( 0 ) 00186 { 00187 OMTRACEID( OMK_DEBUG_OMK_POL, "Polator constructor with fifo" ) ; 00188 initialisePolator(); 00189 _fifo = fifo ; 00190 }
OMK::Type::Polator< T >::Polator | ( | ) | [inline] |
Default constructor.
Definition at line 165 of file OMKPolator.h.
References OMK::Type::Polator< T >::initialisePolator(), OMK_DEBUG_OMK_POL, and OMTRACEID.
00166 : PolatorNT( 0 ) 00167 { 00168 OMTRACEID( OMK_DEBUG_OMK_POL, "Polator default constructor without fifo" ) ; 00169 initialisePolator(); 00170 }
OMK::Type::Polator< T >::Polator | ( | int | numberOfValuesForMaxPrecision | ) | [inline] |
Contructor defining the number of values needed for a miximum precision level .
Definition at line 174 of file OMKPolator.h.
References OMK::Type::Polator< T >::initialisePolator(), OMK_DEBUG_OMK_POL, and OMTRACEID.
00175 : PolatorNT( numberOfValuesForMaxPrecision ) 00176 { 00177 OMTRACEID( OMK_DEBUG_OMK_POL, 00178 "Polator constructor with one parameter and without fifo" ) ; 00179 initialisePolator(); 00180 }
OMK::Type::Polator< T >::~Polator | ( | ) | [inline, virtual] |
const T & OMK::Type::Polator< T >::polate | ( | const int | requestedPrecisionLevel, | |
const Date & | t, | |||
int & | timeDistance, | |||
T & | resultPlaceHolder | |||
) | const |
Generic polation member function.
This member function is not virtual, and called by the output. This member function calls the other member functions when polation is needed.
requestedPrecisionLevel | It is supposed that for polation with level i, i+1 values are needed in the history fifo. | |
t | the date at wich a value is requested. | |
timeDistance | the distance of the return value to the nearest exact value from which it was calculated. | |
resultPlaceHolder | placeholder if the result is not already stored in the history fifo. |
Definition at line 242 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo, OMK::Type::Polator< T >::antepolate(), OMK::Type::PolatorNT::ConstantContinuous, OMK::Type::Polator< T >::extrapolate(), OMK::Type::Polator< T >::get(), OMK::Type::Polator< T >::getDate(), OMK::Type::Polator< T >::getNumberOfPresentValues(), OMK::Type::Polator< T >::interpolate(), OMASSERT, OMASSERTM, OMK_DEBUG_OMK_POL, and OMTRACEID.
00246 { 00247 OMTRACEID( OMK_DEBUG_OMK_POL, 00248 "Polator<" << typeid( T ).name() 00249 << ">::" << this << "::polate (" 00250 << requestedPrecisionLevel << "," << t << ") " ) ; 00251 00252 int requestedPrecisionLevelPossible = requestedPrecisionLevel ; 00253 //_fifo->initialiseContext() ; 00254 int NumberOfPresentValues = getNumberOfPresentValues( 00255 requestedPrecisionLevel + 1 ) ; 00256 00257 OMTRACEID( OMK_DEBUG_OMK_POL, 00258 "Polator<" << typeid( T ).name() 00259 << ">::" << this << "::polate : NumberOfPresentValues : " 00260 << NumberOfPresentValues ) ; 00261 00262 if( NumberOfPresentValues == 0 ) 00263 { 00264 throw EmptyFifoException( "Polator fifo is empty" ) ; 00265 } 00266 00267 // Same test for antepolate and extrapolate 00268 // ------------------------------------------------ 00269 if( NumberOfPresentValues <= requestedPrecisionLevel ) 00270 { 00271 requestedPrecisionLevelPossible = NumberOfPresentValues - 1 ; 00272 } 00273 00274 const Date & dateOfLastValue( getDate( 0 ) ); 00275 00276 OMASSERTM( dateOfLastValue != -1, "Date of last value not initialised" ) ; 00277 00278 if( dateOfLastValue < t || 00279 ( dateOfLastValue == t 00280 && PolatorNT::ConstantContinuous <= requestedPrecisionLevel ) ) 00281 { 00282 OMTRACEID( OMK_DEBUG_OMK_POL, "Extrapolation case" ) ; 00283 timeDistance = t - dateOfLastValue ; 00284 00285 // here, we have to do an extrapolation 00286 // OMASSERT( t != dateOfLastValue ) ; 00287 OMASSERT( NumberOfPresentValues != 1 || 00288 requestedPrecisionLevelPossible == 0 ) ; 00289 return extrapolate( resultPlaceHolder, 00290 requestedPrecisionLevelPossible, 00291 t, 00292 dateOfLastValue ); 00293 } 00294 00295 // Here, current state is : t <= dateOfLastValues 00296 // So, we have 3 cases : 00297 // - we get a value corresponding to t 00298 // - we interpolate 00299 // - we antepolate 00300 int index = 0 ; // nearest index in the fifo corresponding to date t 00301 unsigned int numberOfValuesInFifoNeededToContinueExamination = 2 ; 00302 00303 Date const * examinedDate = & dateOfLastValue ; 00304 Date const * dateExaminedBefore = NULL ; 00305 T const * valueExaminedBefore = NULL ; 00306 00307 bool notFound = true ; // end of iteration 00308 bool exact = false ; // interpolation needed 00309 if( *examinedDate == t ) 00310 { 00311 notFound = false ; 00312 exact = true ; 00313 } 00314 00315 OMTRACEID( OMK_DEBUG_OMK_POL, 00316 "Polator<" << typeid( T ).name() 00317 << ">::polate : finding values loop..." << t ) ; 00318 00319 while( notFound && 00320 ( numberOfValuesInFifoNeededToContinueExamination <= 00321 _fifo->getNumberOfPresentValues( 00322 numberOfValuesInFifoNeededToContinueExamination ) ) ) 00323 { 00324 OMTRACEID( OMK_DEBUG_OMK_POL, "loop status variables : " 00325 << notFound <<" " 00326 << examinedDate <<" " 00327 << exact <<" " 00328 << t <<" " 00329 << index <<" " 00330 << numberOfValuesInFifoNeededToContinueExamination ) ; 00331 dateExaminedBefore = examinedDate ; 00332 valueExaminedBefore = & get( index ) ; 00333 index++ ; 00334 examinedDate = & getDate( index ) ; 00335 00336 if( *examinedDate == t ) 00337 { 00338 notFound = false ; 00339 exact = true ; 00340 } 00341 else if( *examinedDate < t ) 00342 { 00343 notFound = false ; 00344 exact = false ; 00345 } 00346 00347 ++numberOfValuesInFifoNeededToContinueExamination ; 00348 #ifdef _DEBUGATTRIBUTSMOME 00349 if( 4 < index ) 00350 std::cerr << "checking a value further " << NumberOfPresentValues 00351 << " " << examinedDate << " " << t << std::endl ; 00352 #endif 00353 } 00354 00355 if( t < *examinedDate ) 00356 { //because of relaxed coherance, this can sometimes happen 00357 return antepolate( resultPlaceHolder, 00358 requestedPrecisionLevelPossible, 00359 t, 00360 *examinedDate, 00361 index ); 00362 } 00363 00364 // Here, 00365 // dateOfOldestValueAvailable <= examinedDate <= t <= oldExaminedDate <= dateOfLastValue, 00366 // with examinedDate == t if exact 00367 00368 timeDistance = t - *examinedDate ; 00369 if( !exact ) 00370 { 00371 OMASSERTM( dateExaminedBefore != NULL, 00372 "Pointer dateExaminedBefore must be valid" ) ; 00373 OMASSERTM( valueExaminedBefore != NULL, 00374 "Pointer valueExaminedBefore must be valid" ) ; 00375 return interpolate( resultPlaceHolder, 00376 requestedPrecisionLevelPossible, 00377 t, 00378 *dateExaminedBefore, 00379 *valueExaminedBefore, 00380 *examinedDate, 00381 index ) ; 00382 } 00383 else 00384 { 00385 return get( index ) ; 00386 } 00387 }
const T & OMK::Type::Polator< T >::interpolate | ( | T & | resultPlaceHolder, | |
const int | interpolateLevel, | |||
const Date & | dateNeeded, | |||
const Date & | dateAfter, | |||
const T & | valueAfter, | |||
const Date & | dateBefore, | |||
int | offsetToMostRecentOfDateBefore | |||
) | const [inline, virtual] |
Interpolation member function.
interprecisionLevel | requested interpolation level. | |
dateNeeded | date for which a value will be calculated. | |
dateAfter | date of the nearest exact value which date is after dateNeeded. | |
valueAfter | the corresponding value. | |
dateBefore | date of the nearest exact value which date is before dateNeeded. | |
offsetToMostRecentOfDateBefore | getDate( offsetToMostRecentOfDateBefore ) == dateBefore. |
Definition at line 407 of file OMKPolator.h.
References OMK::Type::Polator< T >::get(), OMK_DEBUG_OMK_POL, and OMTRACEID.
Referenced by OMK::Type::Polator< T >::polate().
00414 { 00415 OMTRACEID( OMK_DEBUG_OMK_POL, 00416 "*********************************************" << std::endl 00417 << "Polator<" << typeid( T ).name() 00418 << ">::interpolate (Default)" << std::endl 00419 << "Date dateAfter <----- : " << dateAfter << std::endl 00420 << "Date dateNeeded <----- : " << dateNeeded << std::endl 00421 << "Date dateBefore <----- : " << dateBefore << std::endl 00422 << "T : valueAfter " << valueAfter << std::endl 00423 << "int : offsetToMostRecentOfDateBefore " 00424 << offsetToMostRecentOfDateBefore ) ; 00425 resultPlaceHolder = 00426 ( ( dateAfter - dateNeeded ) <= ( dateNeeded - dateBefore ) ) ? 00427 valueAfter : get( offsetToMostRecentOfDateBefore ) ; 00428 return resultPlaceHolder ; 00429 }
const T & OMK::Type::Polator< T >::extrapolate | ( | T & | resultPlaceHolder, | |
const int | requestedPrecisionLevel, | |||
const Date & | t, | |||
const Date & | tIndex | |||
) | const [inline, virtual] |
Extrapolation member function.
requestedPrecisionLevel | requested extrapolation level | |
t | date for which a value will be calculated. | |
tIndex | date associated to nearest value == getDate( 0 ). |
Definition at line 434 of file OMKPolator.h.
References OMK::Type::Polator< T >::get(), OMK_DEBUG_OMK_POL, and OMTRACEID.
Referenced by OMK::Type::Polator< T >::polate().
00438 { 00439 OMTRACEID( OMK_DEBUG_OMK_POL, 00440 "*********************************************" << std::endl 00441 << "Polator<" << typeid( T ).name() 00442 << ">::extrapolate (Default)" << std::endl 00443 << "Date t <----- : " << t << std::endl 00444 << "Date tIndex <----- : " << tIndex << std::endl 00445 << "Interpolation level : " 00446 << requestedPrecisionLevel << std::endl 00447 << "*********************************************" ) ; 00448 return get( 0 ); 00449 }
const T & OMK::Type::Polator< T >::antepolate | ( | T & | resultPlaceHolder, | |
const int | requestedPrecisionLevel, | |||
const Date & | t, | |||
const Date & | tIndex, | |||
unsigned int | index | |||
) | const [inline, virtual] |
Antepolation member function.
requestedPrecisionLevel | requested antepolation level. | |
t | date for which a value will be calculated. | |
tIndex | date associated to nearest value == getDate( index ). |
Definition at line 454 of file OMKPolator.h.
References OMK::Type::Polator< T >::get(), OMK_DEBUG_OMK_POL, and OMTRACEID.
Referenced by OMK::Type::Polator< T >::polate().
00459 { 00460 OMTRACEID( OMK_DEBUG_OMK_POL, 00461 "*********************************************" << std::endl 00462 << "Polator<" << typeid( T ).name() << ">::antepolate" << std::endl 00463 << "Date t <----- : " << t << std::endl 00464 << "Date tIndex <----- : " << tIndex << std::endl 00465 << "Interpolation level : " << requestedPrecisionLevel 00466 << std::endl 00467 << "index of last element : " << index << std::endl 00468 << "*********************************************" ) ; 00469 return get( index ); 00470 }
void OMK::Type::Polator< T >::setFifo | ( | AbstractFifo< T > * | fifo | ) | [inline] |
update fifo associated with polator
Definition at line 224 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo, OMK_DEBUG_OMK_POL, and OMTRACEID.
00225 { 00226 OMTRACEID( OMK_DEBUG_OMK_POL, "Polator<" << typeid( T ).name() 00227 << ">::setFifo" ) ; 00228 _fifo = fifo ; 00229 }
int OMK::Type::Polator< T >::getNumberOfPresentValues | ( | int | maxNeeded = -1 |
) | const [inline, protected] |
Definition at line 233 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo, OMK_DEBUG_OMK_POL, and OMTRACEID.
Referenced by OMK::Type::NumericPolatorT< Type >::extrapolate(), OMK::Type::ColorPolator::extrapolate(), and OMK::Type::Polator< T >::polate().
00234 { 00235 OMTRACEID( OMK_DEBUG_OMK_POL, "Polator<" << typeid( T ).name() 00236 << ">::getNumberOfPresentValues" ) ; 00237 return _fifo->getNumberOfPresentValues( maxNeeded ) ; 00238 }
const T & OMK::Type::Polator< T >::get | ( | const int | index | ) | const [inline, protected] |
Returns a value of the fifo.
index | index in the fifo. |
Definition at line 207 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo.
Referenced by OMK::Type::Polator< T >::antepolate(), OMK::Type::NumericPolatorT< Type >::antepolate(), OMK::Type::ColorPolator::antepolate(), OMK::Type::Polator< T >::extrapolate(), OMK::Type::NumericPolatorT< Type >::extrapolate(), OMK::Type::ColorPolator::extrapolate(), OMK::Type::Polator< T >::interpolate(), OMK::Type::NumericPolatorT< Type >::interpolate(), OMK::Type::ColorPolator::interpolate(), and OMK::Type::Polator< T >::polate().
00208 { 00209 return _fifo->getPreceedingValue( value ) ; 00210 }
const Date & OMK::Type::Polator< T >::getDate | ( | const int | index | ) | const [inline, protected] |
Returns date of a value in the fifo.
This method has the same behaviour than get.
Definition at line 214 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo, OMK_DEBUG_OMK_POL, and OMTRACEID.
Referenced by OMK::Type::NumericPolatorT< Type >::antepolate(), OMK::Type::ColorPolator::antepolate(), OMK::Type::NumericPolatorT< Type >::extrapolate(), OMK::Type::ColorPolator::extrapolate(), OMK::Type::NumericPolatorT< Type >::interpolate(), OMK::Type::ColorPolator::interpolate(), and OMK::Type::Polator< T >::polate().
00215 { 00216 OMTRACEID( OMK_DEBUG_OMK_POL, 00217 "Polator<" << typeid( T ).name() 00218 << ">::" << this << "::getDate( " << value << " )"); 00219 return _fifo->getPreceedingDate( value ) ; 00220 }
void OMK::Type::Polator< T >::initialisePolator | ( | ) | [inline, private] |
Initialises the Polator.
Definition at line 194 of file OMKPolator.h.
References OMK::Type::Polator< T >::_fifo.
Referenced by OMK::Type::Polator< T >::Polator().
00195 { 00196 _fifo = NULL ; 00197 }
AbstractFifo<T>* OMK::Type::Polator< T >::_fifo [protected] |
Pointer to the fifo with values of an ouput.
Definition at line 139 of file OMKPolator.h.
Referenced by OMK::Type::Polator< T >::get(), OMK::Type::Polator< T >::getDate(), OMK::Type::Polator< T >::getNumberOfPresentValues(), OMK::Type::Polator< T >::initialisePolator(), OMK::Type::Polator< T >::polate(), OMK::Type::Polator< T >::Polator(), and OMK::Type::Polator< T >::setFifo().
Documentation generated on Mon Jun 9 11:46:05 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |