casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
casacore::FunctionWrapper< T > Class Template Reference

Construct nD function objects from C++ functions. More...

#include <FunctionWrapper.h>

Inheritance diagram for casacore::FunctionWrapper< T >:
casacore::WrapperParam< T > casacore::Function< T > casacore::Functional< FunctionTraits< T >::ArgType, U > casacore::Functional< Vector< FunctionTraits< T >::ArgType >, U >

Public Member Functions

 FunctionWrapper ()
 Default constructor, to enable arrays. More...
 
 FunctionWrapper (T(*f)())
 A function with no parameters and no arguments. More...
 
 FunctionWrapper (T(*f)(const T &), const Bool isPar)
 A function with parameter and no arguments (Note value of isPar irrelevant) More...
 
 FunctionWrapper (T(*f)(const Vector< T > &), const Bool isPar)
 A function with parameters and no arguments. More...
 
 FunctionWrapper (T(*f)(const T &))
 Construct a 1-dimensional function with no parameters. More...
 
 FunctionWrapper (T(*f)(const T &, const T &), const T &par)
 Construct a 1-dimensional function with parameter. More...
 
 FunctionWrapper (T(*f)(const T &, const Vector< T > &), const Vector< T > &par)
 Construct a 1-dimensional function with parameters. More...
 
 FunctionWrapper (T(*f)(const Vector< T > &), const Int dim=1)
 Construct an n-dimensional function with no parameters. More...
 
 FunctionWrapper (T(*f)(const Vector< T > &, const T &), const T &par, const uInt dim=1)
 Construct an n-dimensional function with parameter. More...
 
 FunctionWrapper (T(*f)(const Vector< T > &, const Vector< T > &), const Vector< T > &par, const uInt dim=1)
 Construct an n-dimensional function with parameters. More...
 
 FunctionWrapper (const FunctionWrapper< T > &other)
 Copy constructor (reference semantics) More...
 
FunctionWrapper< T > & operator= (const FunctionWrapper< T > &other)
 Copy assignment (reference semantics) More...
 
virtual ~FunctionWrapper ()
 Destructor. More...
 
virtual T eval (typename Function< T >::FunctionArg x) const
 Evaluate the function at x. More...
 
virtual uInt ndim () const
 Get the dimensionality. More...
 
virtual Function< T > * clone () const
 Return a copy of this object from the heap. More...
 
- Public Member Functions inherited from casacore::WrapperParam< T >
 WrapperParam ()
 Construct with the given parameters. More...
 
 WrapperParam (const T &par)
 
 WrapperParam (const Vector< T > &par)
 
 WrapperParam (const WrapperParam< T > &other)
 Copy constructor (deep copy) More...
 
WrapperParam< T > & operator= (const WrapperParam< T > &other)
 Copy assignment (deep copy) More...
 
virtual ~WrapperParam ()
 Destructor. More...
 
virtual const Stringname () const
 Give name of function. More...
 
- Public Member Functions inherited from casacore::Function< T >
 Function ()
 Constructors. More...
 
 Function (const uInt n)
 
 Function (const Vector< T > &in)
 
 Function (const FunctionParam< T > &other)
 
 Function (const Function< W, X > &other)
 
virtual ~Function ()
 Destructor. More...
 
uInt nparameters () const
 Returns the number of parameters. More...
 
virtual U eval (FunctionArg x) const =0
 Evaluate the function object. More...
 
T & operator[] (const uInt n)
 Manipulate the nth parameter (0-based) with no index check. More...
 
const T & operator[] (const uInt n) const
 
virtual U operator() () const
 Evaluate this function object at xor at x, y. More...
 
virtual U operator() (const ArgType &x) const
 
virtual U operator() (const Vector< ArgType > &x) const
 
virtual U operator() (FunctionArg x) const
 
virtual U operator() (const ArgType &x, const ArgType &y) const
 
virtual U operator() (const ArgType &x, const ArgType &y, const ArgType &z) const
 
Boolmask (const uInt n)
 Manipulate the mask associated with the nth parameter (e.g. More...
 
const Boolmask (const uInt n) const
 
const FunctionParam< T > & parameters () const
 Return the parameter interface. More...
 
FunctionParam< T > & parameters ()
 
const Vector< ArgType > & argp () const
 Get arg_p and parset_p. More...
 
Bool parsetp () const
 
void lockParam ()
 Compiler cannot always find the correct 'const' version of parameter access. More...
 
void unlockParam ()
 
virtual void setMode (const RecordInterface &mode)
 get/set the function mode. More...
 
virtual void getMode (RecordInterface &mode) const
 
virtual Bool hasMode () const
 return True if the implementing function supports a mode. More...
 
ostream & print (ostream &os) const
 Print the function (i.e. More...
 
virtual Function< typename
FunctionTraits< T >::DiffType > * 
cloneAD () const
 
virtual Function< typename
FunctionTraits< T >::BaseType > * 
cloneNonAD () const
 
- Public Member Functions inherited from casacore::Functional< FunctionTraits< T >::ArgType, U >
virtual ~Functional ()
 Destructor. More...
 
virtual U operator() (const FunctionTraits< T >::ArgType &x) const =0
 Map a Domain x into a Range y value. More...
 
- Public Member Functions inherited from casacore::Functional< Vector< FunctionTraits< T >::ArgType >, U >
virtual ~Functional ()
 Destructor. More...
 
virtual U operator() (const Vector< FunctionTraits< T >::ArgType > &x) const =0
 Map a Domain x into a Range y value. More...
 

Protected Attributes

CountedPtr< WrapperBase< T > > doit_p
 The function aid object. More...
 
- Protected Attributes inherited from casacore::Function< T >
FunctionParam< T > param_p
 The parameters and masks. More...
 
Vector< ArgTypearg_p
 Aid for non-contiguous argument storage. More...
 
Bool parset_p
 Indicate parameter written. More...
 
Bool locked_p
 Indicate that parameters are expected to be locked from changing. More...
 

Additional Inherited Members

- Public Types inherited from casacore::Function< T >
typedef FunctionTraits< T >
::ArgType 
ArgType
 
typedef const ArgTypeFunctionArg
 

Detailed Description

template<class T>
class casacore::FunctionWrapper< T >

Construct nD function objects from C++ functions.

Intended use:

Public interface

Review Status

Date Reviewed:
1996/02/22

Prerequisite

Synopsis

This class is provided so that user can quickly construct a function object from a C++ function pointer without having to write a function class. The constructor constructs a function object from a function pointer, and an optional parameter list. Parameters are necessary if the function has to be used in a functional fitting process (see GenericL2Fit).

The general function signature is f(x;p), where x represents the arguments, and p the parameters. The allowed signatures of the function include all combinations of arguments and parameters, and are:

Example

Float func(const Vector<Float>& x) {return x(0)*x(1);} // x*y
// Convert C++ functions to Functionals
FunctionWrapper<Float> Func(func,2);

Definition at line 85 of file FunctionWrapper.h.

Constructor & Destructor Documentation

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( )

Default constructor, to enable arrays.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)()  f)

A function with no parameters and no arguments.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const T &)  f,
const Bool  isPar 
)

A function with parameter and no arguments (Note value of isPar irrelevant)

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const Vector< T > &)  f,
const Bool  isPar 
)

A function with parameters and no arguments.

(Note value of isPar irrelevant)

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const T &)  f)

Construct a 1-dimensional function with no parameters.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const T &, const T &)  f,
const T &  par 
)

Construct a 1-dimensional function with parameter.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const T &, const Vector< T > &)  f,
const Vector< T > &  par 
)

Construct a 1-dimensional function with parameters.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const Vector< T > &)  f,
const Int  dim = 1 
)

Construct an n-dimensional function with no parameters.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const Vector< T > &, const T &)  f,
const T &  par,
const uInt  dim = 1 
)

Construct an n-dimensional function with parameter.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( T(*)(const Vector< T > &, const Vector< T > &)  f,
const Vector< T > &  par,
const uInt  dim = 1 
)

Construct an n-dimensional function with parameters.

template<class T>
casacore::FunctionWrapper< T >::FunctionWrapper ( const FunctionWrapper< T > &  other)

Copy constructor (reference semantics)

template<class T>
virtual casacore::FunctionWrapper< T >::~FunctionWrapper ( )
inlinevirtual

Destructor.

Definition at line 122 of file FunctionWrapper.h.

Member Function Documentation

template<class T>
virtual Function<T>* casacore::FunctionWrapper< T >::clone ( ) const
inlinevirtual

Return a copy of this object from the heap.

The caller is responsible for deleting this pointer.

Implements casacore::Function< T >.

Definition at line 136 of file FunctionWrapper.h.

template<class T>
virtual T casacore::FunctionWrapper< T >::eval ( typename Function< T >::FunctionArg  x) const
virtual

Evaluate the function at x.

template<class T>
virtual uInt casacore::FunctionWrapper< T >::ndim ( ) const
virtual

Get the dimensionality.

Implements casacore::Function< T >.

template<class T>
FunctionWrapper<T>& casacore::FunctionWrapper< T >::operator= ( const FunctionWrapper< T > &  other)

Copy assignment (reference semantics)

Member Data Documentation

template<class T>
CountedPtr<WrapperBase<T> > casacore::FunctionWrapper< T >::doit_p
protected

The function aid object.

Definition at line 143 of file FunctionWrapper.h.


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