18 #ifndef __itkCacheableScalarFunction_h
19 #define __itkCacheableScalarFunction_h
58 class CacheableScalarFunction
62 CacheableScalarFunction();
65 virtual ~CacheableScalarFunction() {}
68 typedef double MeasureType;
73 SizeValueType GetNumberOfSamples() {
return m_NumberOfSamples; }
76 bool IsCacheAvailable() {
return m_CacheAvailable; }
79 double GetCacheUpperBound() {
return m_CacheUpperBound; }
82 double GetCacheLowerBound() {
return m_CacheLowerBound; }
87 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