casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
casacore::Functional< Domain, Range > Class Template Referenceabstract

Map a domain object into a range object via operator(). More...

#include <Functional.h>

Inheritance diagram for casacore::Functional< Domain, Range >:
casacore::Function< AutoDiff< T > > casacore::Function< AutoDiff< T > > casacore::Function< casacore::AutoDiff< Double > > casacore::Function< casacore::AutoDiff< Double > > casacore::Function< casacore::Double > casacore::Function< casacore::Double > casacore::Function< Type > casacore::Function< Type > casacore::Function< typename casacore::FunctionTraits< casacore::Float >::DiffType, typename casacore::FunctionTraits< casacore::Float >::DiffType > casacore::Function< typename casacore::FunctionTraits< casacore::Float >::DiffType, typename casacore::FunctionTraits< casacore::Float >::DiffType > casacore::Function< typename casacore::FunctionTraits< DComplex >::DiffType, typename casacore::FunctionTraits< DComplex >::DiffType > casacore::Function< typename casacore::FunctionTraits< DComplex >::DiffType, typename casacore::FunctionTraits< DComplex >::DiffType > casacore::Function< typename casacore::FunctionTraits< Double >::DiffType, typename casacore::FunctionTraits< Double >::DiffType > casacore::Function< typename casacore::FunctionTraits< Double >::DiffType, typename casacore::FunctionTraits< Double >::DiffType > casacore::Function< typename casacore::FunctionTraits< Float >::DiffType, typename casacore::FunctionTraits< Float >::DiffType > casacore::Function< typename casacore::FunctionTraits< Float >::DiffType, typename casacore::FunctionTraits< Float >::DiffType > casacore::Function< typename casacore::FunctionTraits< T >::DiffType, typename casacore::FunctionTraits< T >::DiffType > casacore::Function< typename casacore::FunctionTraits< T >::DiffType, typename casacore::FunctionTraits< T >::DiffType > casacore::SampledFunctional< T >

Public Member Functions

virtual ~Functional ()
 Destructor. More...
 
virtual Range operator() (const Domain &x) const =0
 Map a Domain x into a Range y value. More...
 

Detailed Description

template<class Domain, class Range>
class casacore::Functional< Domain, Range >

Map a domain object into a range object via operator().

Intended use:

Public interface

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Etymology

The term Functional'' was chosen to follow the usage in Barton and Nackman'sScientific and Engineering C++.''

Synopsis

A Functional<Domain,Range> is an abstract base class which encapsulates the mapping of an object of type Domain into an object of type Range. This operation is invoked via operator() to make it look like a function call.

While these functions are function-like, there is no guarantee that evaluations of the same parameter will yield the same result (the implementor of a particular class could, for example, merely choose to emit a random number). However implementors of Functional classes are strongly encouraged to implement (visible) side-effect free semantics in their classes.

A Functional object is used in circumstances similar to those in which a function pointer could be used. An advantage of the Functional objects is that it is possible to have more than one of them at the same time. Another potential advantage (not yet implemented) is that it will be possible to perform functional composition at run time, e.g. a=b+c where a,b, and c are Functionals. Another advantage is that since the Functional implementations will in general be templated, the same source code would yield instantiations for all the numeric types and for specializations like automatic derivatives.

To be of greatest utility, a library of functions that do mathematics, plotting, etc. on Functional objects needs to be developed.

Example

The following simple example shows how you can write a function that uses a Functional object.

Double integrate1D(const Functional<Float,Float> &f,
Double x1, Double x2, Double dx) {
uInt n = (xend - xstart) / dx;
Double sum = 0.0;
for (uInt i=0; i < n; i++) sum += f(x1 + i*dx) * dx;
return sum;
}

Obviously this isn't a very serious algorithm!

Motivation

The specific application that caused the implementation of these Functional classes was the creation of the Fitting module, which needed classes to represent the fitting functions.

Template Type Argument Requirements (Domain)

Template Type Argument Requirements (Range)

To Do

Definition at line 122 of file Functional.h.

Constructor & Destructor Documentation

template<class Domain, class Range>
virtual casacore::Functional< Domain, Range >::~Functional ( )
virtual

Destructor.

Member Function Documentation

template<class Domain, class Range>
virtual Range casacore::Functional< Domain, Range >::operator() ( const Domain &  x) const
pure virtual

Map a Domain x into a Range y value.

Implemented in casacore::SampledFunctional< Range >.


The documentation for this class was generated from the following file: