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

itk::CacheableScalarFunction Class Reference

function cache implementation. More...

#include <itkCacheableScalarFunction.h>

Inheritance diagram for itk::CacheableScalarFunction:

Inheritance graph
[legend]
Collaboration diagram for itk::CacheableScalarFunction:

Collaboration graph
[legend]
List of all members.

Public Types

typedef double MeasureType
typedef Array< MeasureTypeMeasureArrayType

Public Methods

 CacheableScalarFunction ()
virtual ~CacheableScalarFunction ()
long GetNumberOfSamples ()
bool IsCacheAvailable ()
double GetCacheHigherBound ()
double GetCacheLowerBound ()
virtual MeasureType Evaluate (MeasureType x)
MeasureType GetCachedValue (MeasureType x)

Protected Methods

void CreateCache (double lowerBound, double higherBound, long sampleSize)

Detailed Description

function cache implementation.

This is the base class for continuous scalar functions which needs cache for their pre-evaluated function returns.

The internal cache is created using the upper- and lower-bound domain values of the functional form (f(x))of subclasses of this class. So the cache only stores pre-evaluated values between f(lower-bound) and f(upper-bound).

To create a cache for continuous function, it uses sampling. With the given sample number , upper-bound, and lower-bound, it calculates interval within the ranges. It pre-evaluates and save f(x) where x = lower-bound + interval * [0 - sample number]

If a subclass of this class want to use a cache, it should explicitly call CreateCache(...) member function. GetCachedValue(x) will return pre-evaluated f(x) value. However, the return value from GetCachedValue(x) might be different from the exact return value from f(x) which is Evaluate(x) member function of subclasses of this class, because The GetCachedValue(x) member function internally converts x to cache table index and the conversion involves with truncation. So, users can think the cached value as an approximate to exact function return.

In some case, approximate values can be useful. For example, CompositeValleyFunction can be used as an M-estimator and it is currently used for MRIBiasFieldCorrectionFilter as an energy function. The bias field estimation requires calculation of energy values again and again for each iteration.

Definition at line 55 of file itkCacheableScalarFunction.h.


Member Typedef Documentation

typedef Array<MeasureType> itk::CacheableScalarFunction::MeasureArrayType
 

Reimplemented in itk::CompositeValleyFunction.

Definition at line 66 of file itkCacheableScalarFunction.h.

typedef double itk::CacheableScalarFunction::MeasureType
 

Function's input and output value type.

Reimplemented in itk::CompositeValleyFunction.

Definition at line 65 of file itkCacheableScalarFunction.h.

Referenced by Evaluate(), and GetCachedValue().


Constructor & Destructor Documentation

itk::CacheableScalarFunction::CacheableScalarFunction  
 

Constructor.

virtual itk::CacheableScalarFunction::~CacheableScalarFunction   [inline, virtual]
 

Destructor.

Definition at line 62 of file itkCacheableScalarFunction.h.


Member Function Documentation

void itk::CacheableScalarFunction::CreateCache double    lowerBound,
double    higherBound,
long    sampleSize
[protected]
 

Create the internal cache table and fill it with pre-evaluated values.

virtual MeasureType itk::CacheableScalarFunction::Evaluate MeasureType    x [inline, virtual]
 

y = f(x) Subclasses of this class should override this member function to provide their own functional operation .

Reimplemented in itk::CompositeValleyFunction.

Definition at line 84 of file itkCacheableScalarFunction.h.

References MeasureType.

MeasureType itk::CacheableScalarFunction::GetCachedValue MeasureType    x [inline]
 

y = f(x) = (approximately) cache_table(index(x)) Get the function return using the internal cache table NOTE: Since the index calculation needs conversion from double to int, truncation happens. As a result, the return values from Evaluate(x) and GetCachedValue(x) may not be same for the same x.

Definition at line 92 of file itkCacheableScalarFunction.h.

References MeasureType.

double itk::CacheableScalarFunction::GetCacheHigherBound   [inline]
 

Get the upper-bound of domain that is used for filling the cache table.

Definition at line 76 of file itkCacheableScalarFunction.h.

double itk::CacheableScalarFunction::GetCacheLowerBound   [inline]
 

Get the lower-bound of domain that is used for filling the cache table.

Definition at line 79 of file itkCacheableScalarFunction.h.

long itk::CacheableScalarFunction::GetNumberOfSamples void    [inline]
 

Get the number of samples between the lower-bound and higher-bound of the cache table.

Definition at line 70 of file itkCacheableScalarFunction.h.

bool itk::CacheableScalarFunction::IsCacheAvailable   [inline]
 

Check if the internal cache table and its values are valid.

Definition at line 73 of file itkCacheableScalarFunction.h.


The documentation for this class was generated from the following file:
Generated at Fri May 21 01:18:35 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000