Template Class Function

Inheritance Relationships

Base Types

Derived Types

Class Documentation

template<typename ReturnT>
class Function : public lsst::afw::table::io::PersistableFacade<Function<ReturnT>>, public lsst::afw::table::io::Persistable

Basic Function class.

Function objects are functions whose parameters may be read and changed using getParameters and setParameters. They were designed for use with the Kernel class.

These are simple functors with the restrictions that:

  • Function arguments and parameters are double precision

  • The return type is templated

To create a function for a particular equation, subclass Function or (much more likely) Function1 or Function2. Your subclass must:

  • Have one or more constructors, all of which must initialize _params

  • Define operator() with code to compute the function using this->_params or this->getParams() to reference the parameters

  • If the function is a linear combination of parameters then override the function isLinearCombination.

If you wish to cache any information you may use the _isCacheValid flag; this is automatically set false whenever parameters are changed.

Design Notes: The reason these functions exist (rather than using a pre-existing function class, such as Functor in VisualWorkbench) is because the Kernel class requires function objects with a standard interface for setting and getting function parameters.

The reason isLinearCombination exists is to support refactoring LinearCombinationKernels.

Subclassed by lsst::afw::math::Function1< ReturnT >, lsst::afw::math::Function2< ReturnT >

Public Functions

Function(unsigned int nParams)

Parameters
  • nParams: number of function parameters

Construct a Function given the number of function parameters.

The function parameters are initialized to 0.

Function(std::vector<double> const &params)

Parameters
  • params: function parameters

Construct a Function given the function parameters.

Function(Function const&)
Function(Function&&)
Function &operator=(Function const&)
Function &operator=(Function&&)
~Function()
unsigned int getNParameters() const

Return the number of function parameters

Return

the number of function parameters

virtual double getParameter(unsigned int ind) const

Parameters
  • ind: index of parameter

Get one function parameter without range checking

Return

the specified function parameter

std::vector<double> const &getParameters() const

Return all function parameters

Return

the function parameters as a vector

virtual bool isLinearCombination() const

Is the function a linear combination of its parameters?

Return

true if the function can be expressed as: sum over i of parameter_i * function_i(args)

Warning

: subclasses must override if true.

void setParameter(unsigned int ind, double newValue)

Parameters
  • ind: index of parameter

  • newValue: new value for parameter

Set one function parameter without range checking

void setParameters(std::vector<double> const &params)

Parameters
  • params: vector of function parameters

Set all function parameters

Exceptions
  • lsst::pex::exceptions::InvalidParameterError: if the wrong number of parameters is supplied.

virtual std::string toString(std::string const&) const

Return a string representation of the function

Return

a string representation of the function

Protected Functions

std::string getPythonModule() const

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

Function()

Protected Attributes

std::vector<double> _params
bool _isCacheValid