18 #ifndef itkCacheableScalarFunction_h
19 #define itkCacheableScalarFunction_h
23 #include "ITKBiasCorrectionExport.h"
59 class ITKBiasCorrection_EXPORT CacheableScalarFunction
63 CacheableScalarFunction();
66 virtual ~CacheableScalarFunction();
69 typedef double MeasureType;
74 SizeValueType GetNumberOfSamples() {
return m_NumberOfSamples; }
77 bool IsCacheAvailable() {
return m_CacheAvailable; }
80 double GetCacheUpperBound() {
return m_CacheUpperBound; }
83 double GetCacheLowerBound() {
return m_CacheLowerBound; }
88 virtual MeasureType Evaluate(MeasureType x);
92 {
return m_TableInc; }
99 inline MeasureType GetCachedValue(MeasureType x)
101 if ( x > m_CacheUpperBound || x < m_CacheLowerBound )
103 throw ExceptionObject(__FILE__, __LINE__);
106 int index = (int)( ( x - m_CacheLowerBound ) / m_TableInc );
107 return m_CacheTable[index];
114 void CreateCache(
double lowerBound,
double upperBound,
SizeValueType sampleSize);
122 MeasureArrayType m_CacheTable;
125 double m_CacheUpperBound;
128 double m_CacheLowerBound;
unsigned long SizeValueType