casa
5.7.0-16
|
Numerical functional interface class. More...
#include <SpectralElement.h>
Public Types | |
typedef FunctionTraits< T > ::ArgType | ArgType |
typedef const ArgType * | FunctionArg |
Public Member Functions | |
Function () | |
Constructors. More... | |
Function (const uInt n) | |
Function (const Vector< T > &in) | |
Function (const FunctionParam< T > &other) | |
template<class W , class X > | |
Function (const Function< W, X > &other) | |
Function (const Function< T, U > &other) | |
virtual | ~Function () |
Destructor. More... | |
virtual uInt | ndim () const =0 |
Returns the number of dimensions of function. 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 x or 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 |
virtual const String & | name () const |
Specify the name associated with the function (default will be unknown ) More... | |
Bool & | mask (const uInt n) |
Manipulate the mask associated with the nth parameter (e.g. More... | |
const Bool & | mask (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< T, U > * | clone () const =0 |
Return a copy of this object from the heap. 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 | |
FunctionParam< T > | param_p |
The parameters and masks. More... | |
Vector< ArgType > | arg_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... | |
Numerical functional interface class.
Public interface
A Function
is used for classes which map a scalar or n-dimensional Vector of type T
into a T
. The object also has zero or more parameters which can be masked if necessary, and be used in the Fitting
module, and, implicitly, in the AutoDiff differentiation module.
The parameter interface is provided by the FunctionParam
class.
A Function can have a name()
which can be used in generic interfaces.
The function calls implemented are:
operator()()
operator()(const T &x)
operator()(const Vector<T> &x)
operator()(Function::FunctionArg x)
operator()(const T &x, const T &y)
(for 2D) operator()(const T &x, const T &y, const T &z)
(for 3D) The T
in the above is the Function::ArgType
as derived from the FunctionTraits class. These calls are (in debug mode) tested for the correct number of arguments, after which they call a T eval(FunctionArg x) const = 0
to be implemented in derived classes. The derived class should also implement an uInt ndim() const = 0
. The derived class can access the nth parameter with the [n]
operator, and the corresponding mask with mask(n)
method. The variables are referenced with x[i]
.
A complete implementation of say an A.sin(2pi.f.x)
with parameters amplitude(A) and frequency(f) and variable time(x) could be:
The following will calculate the value and the derivative for A=2; f=3; x=0.1;
A shorter version, where all parameter handling is done at user level could be:
The following will calculate the value and the derivative for A=2; f=3; x=0.1;
A function of more than one variable was required for a function which represents the sky brightness. Adjustable parameters were required for non-linear least squares fitting.
Vector<T>
. Definition at line 38 of file SpectralElement.h.
typedef FunctionTraits<T>::ArgType casacore::Function< T, U >::ArgType |
Definition at line 206 of file Function.h.
typedef const ArgType* casacore::Function< T, U >::FunctionArg |
Definition at line 207 of file Function.h.
|
inline |
Constructors.
Definition at line 212 of file Function.h.
|
inlineexplicit |
Definition at line 213 of file Function.h.
|
inlineexplicit |
Definition at line 215 of file Function.h.
|
inline |
Definition at line 217 of file Function.h.
|
inline |
Definition at line 220 of file Function.h.
|
inline |
Definition at line 222 of file Function.h.
|
inlinevirtual |
Destructor.
Definition at line 233 of file Function.h.
|
inline |
Get arg_p
and parset_p
.
Necessary for reasons of protection in the copying of non-conforming Functions.
Definition at line 286 of file Function.h.
|
pure virtual |
Return a copy of this object from the heap.
The caller is responsible for deleting this pointer. The cloneAD
will return a clone with an AutoDef<T>
; the cloneNonAD
a clone with <T>
. An AipsError
will be thrown if the cloneAD()
or cloneNonAD()
is not implemented for a specific function.
Implemented in casacore::Chebyshev< T >, casacore::Gaussian2D_PS< AutoDiff< T > >, casacore::Gaussian3D_PS< AutoDiff< T > >, casacore::Lorentzian1D_PS< AutoDiff< T > >, casacore::Gaussian1D_PS< AutoDiff< T > >, casacore::SimButterworthBandpass< T >, casacore::CompoundFunction_PS< AutoDiff< T > >, casacore::Sinusoid1D_PS< AutoDiff< T > >, casacore::GaussianND< T >, casacore::Gaussian2D< T >, casacore::Gaussian2D< casacore::Double >, casacore::Interpolate1D< Domain, Range >, casacore::Interpolate1D< Double, Double >, casacore::Interpolate1D< casacore::Float, casacore::casacore::Array< casacore::Float > >, casacore::CombiFunction_PS< AutoDiff< T > >, casacore::MarshallableChebyshev< T >, casacore::HyperPlane_PS< AutoDiff< T > >, casacore::ConstantND_PS< AutoDiff< T > >, casacore::PoissonFunction_PS< AutoDiff< T > >, casacore::Polynomial_PS< AutoDiff< T > >, casacore::Gaussian3D< T >, casacore::OddPolynomial_PS< AutoDiff< T > >, casacore::EvenPolynomial_PS< AutoDiff< T > >, casacore::Lorentzian1D< T >, casacore::Gaussian1D< T >, casacore::PowerLogarithmicPolynomial_PS< AutoDiff< T > >, casacore::CompiledFunction< T >, casacore::MarshButterworthBandpass< T >, casacore::Sinusoid1D< T >, casacore::CompoundFunction< T >, casacore::CompoundFunction< casacore::AutoDiff< Double > >, casacore::CombiFunction< T >, casacore::HyperPlane< T >, casacore::FunctionWrapper< T >, casacore::ConstantND< T >, casacore::SincFunction< T >, casacore::UnaryFunction< T >, casacore::DiracDFunction< T >, casacore::Polynomial< T >, casacore::Polynomial< Double >, casacore::Polynomial< casacore::casacore::AutoDiff< casacore::Float > >, casacore::KaiserBFunction< T >, casacore::PoissonFunction< T >, casacore::OddPolynomial< T >, casacore::EvenPolynomial< T >, casacore::GNoiseFunction< T >, casacore::SPolynomial< T >, and casacore::PowerLogarithmicPolynomial< T >.
|
virtual |
Reimplemented in casacore::Gaussian2D_PS< AutoDiff< T > >, casacore::Gaussian3D_PS< AutoDiff< T > >, casacore::Lorentzian1D_PS< AutoDiff< T > >, casacore::Gaussian1D_PS< AutoDiff< T > >, casacore::CompoundFunction_PS< AutoDiff< T > >, casacore::Sinusoid1D_PS< AutoDiff< T > >, casacore::Gaussian2D< T >, casacore::Gaussian2D< casacore::Double >, casacore::CombiFunction_PS< AutoDiff< T > >, casacore::HyperPlane_PS< AutoDiff< T > >, casacore::ConstantND_PS< AutoDiff< T > >, casacore::PoissonFunction_PS< AutoDiff< T > >, casacore::Polynomial_PS< AutoDiff< T > >, casacore::Gaussian3D< T >, casacore::OddPolynomial_PS< AutoDiff< T > >, casacore::EvenPolynomial_PS< AutoDiff< T > >, casacore::PowerLogarithmicPolynomial_PS< AutoDiff< T > >, casacore::Lorentzian1D< T >, casacore::Gaussian1D< T >, casacore::CompiledFunction< T >, casacore::CompoundFunction< T >, casacore::Sinusoid1D< T >, casacore::CompoundFunction< casacore::AutoDiff< Double > >, casacore::CombiFunction< T >, casacore::HyperPlane< T >, casacore::ConstantND< T >, casacore::SincFunction< T >, casacore::UnaryFunction< T >, casacore::DiracDFunction< T >, casacore::Polynomial< T >, casacore::Polynomial< Double >, casacore::Polynomial< casacore::casacore::AutoDiff< casacore::Float > >, casacore::KaiserBFunction< T >, casacore::PoissonFunction< T >, casacore::OddPolynomial< T >, casacore::EvenPolynomial< T >, casacore::SPolynomial< T >, and casacore::PowerLogarithmicPolynomial< T >.
|
virtual |
Reimplemented in casacore::Gaussian2D_PS< AutoDiff< T > >, casacore::Gaussian3D_PS< AutoDiff< T > >, casacore::Lorentzian1D_PS< AutoDiff< T > >, casacore::Gaussian1D_PS< AutoDiff< T > >, casacore::CompoundFunction_PS< AutoDiff< T > >, casacore::Sinusoid1D_PS< AutoDiff< T > >, casacore::Gaussian2D< T >, casacore::Gaussian2D< casacore::Double >, casacore::CombiFunction_PS< AutoDiff< T > >, casacore::HyperPlane_PS< AutoDiff< T > >, casacore::ConstantND_PS< AutoDiff< T > >, casacore::PoissonFunction_PS< AutoDiff< T > >, casacore::Polynomial_PS< AutoDiff< T > >, casacore::OddPolynomial_PS< AutoDiff< T > >, casacore::EvenPolynomial_PS< AutoDiff< T > >, casacore::Gaussian3D< T >, casacore::PowerLogarithmicPolynomial_PS< AutoDiff< T > >, casacore::Lorentzian1D< T >, casacore::Gaussian1D< T >, casacore::CompiledFunction< T >, casacore::CompoundFunction< T >, casacore::Sinusoid1D< T >, casacore::CompoundFunction< casacore::AutoDiff< Double > >, casacore::CombiFunction< T >, casacore::HyperPlane< T >, casacore::ConstantND< T >, casacore::SincFunction< T >, casacore::UnaryFunction< T >, casacore::DiracDFunction< T >, casacore::Polynomial< T >, casacore::Polynomial< Double >, casacore::Polynomial< casacore::casacore::AutoDiff< casacore::Float > >, casacore::KaiserBFunction< T >, casacore::PoissonFunction< T >, casacore::OddPolynomial< T >, casacore::EvenPolynomial< T >, casacore::SPolynomial< T >, and casacore::PowerLogarithmicPolynomial< T >.
|
pure virtual |
Evaluate the function object.
Referenced by casacore::Function< Type >::operator()().
|
virtual |
|
virtual |
return True if the implementing function supports a mode.
The default implementation returns False.
Reimplemented in casacore::ChebyshevParamModeImpl< T >, and casacore::SimButterworthBandpass< T >.
|
inline |
Compiler cannot always find the correct 'const' version of parameter access.
In cases where this would lead to excessive overheads in moving parameters around (like in CompoundFunction
) the parameter changing can be set to be locked, and no changes are assumed.
Definition at line 295 of file Function.h.
|
inline |
Manipulate the mask associated with the nth parameter (e.g.
to indicate whether the parameter is adjustable or nonadjustable). Note: no index check.
Definition at line 274 of file Function.h.
|
inline |
Definition at line 276 of file Function.h.
|
virtual |
Specify the name associated with the function (default will be unknown
)
Reimplemented in casacore::ChebyshevParam< T >, casacore::ChebyshevParam< AutoDiff< T > >, casacore::ChebyshevParam< AutoDiffA< T > >, casacore::Gaussian2DParam< T >, casacore::Gaussian2DParam< AutoDiff< T > >, casacore::Gaussian2DParam< casacore::Double >, casacore::GaussianNDParam< T >, casacore::Gaussian3DParam< Type >, casacore::Gaussian3DParam< AutoDiff< T > >, casacore::Gaussian3DParam< T >, casacore::Interpolate1D< Domain, Range >, casacore::Interpolate1D< Double, Double >, casacore::Interpolate1D< casacore::Float, casacore::casacore::Array< casacore::Float > >, casacore::CompoundParam< T >, casacore::CompoundParam< casacore::AutoDiff< Double > >, casacore::CompoundParam< AutoDiff< T > >, casacore::Gaussian1DParam< T >, casacore::Lorentzian1DParam< T >, casacore::Gaussian1DParam< AutoDiff< T > >, casacore::Lorentzian1DParam< AutoDiff< T > >, casacore::CombiParam< T >, casacore::CombiParam< AutoDiff< T > >, casacore::Sinusoid1DParam< T >, casacore::HyperPlaneParam< T >, casacore::Sinusoid1DParam< AutoDiff< T > >, casacore::HyperPlaneParam< AutoDiff< T > >, casacore::ConstantNDParam< T >, casacore::ConstantNDParam< AutoDiff< T > >, casacore::SPolynomialParam< T >, casacore::OddPolynomialParam< T >, casacore::PolynomialParam< T >, casacore::OddPolynomialParam< AutoDiff< T > >, casacore::PolynomialParam< Double >, casacore::PolynomialParam< AutoDiff< T > >, casacore::PolynomialParam< casacore::casacore::AutoDiff< casacore::Float > >, casacore::EvenPolynomialParam< T >, casacore::EvenPolynomialParam< AutoDiff< T > >, casacore::CompiledParam< T >, casacore::PowerLogarithmicPolynomialParam< T >, casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >, casacore::SincParam< T >, casacore::UnaryParam< T >, casacore::DiracDParam< T >, casacore::PoissonParam< T >, casacore::PoissonParam< AutoDiff< T > >, casacore::KaiserBParam< T >, casacore::GNoiseParam< T >, and casacore::WrapperParam< T >.
|
pure virtual |
Returns the number of dimensions of function.
Implemented in casacore::Gaussian2DParam< T >, casacore::Gaussian2DParam< AutoDiff< T > >, casacore::Gaussian2DParam< casacore::Double >, casacore::GaussianNDParam< T >, casacore::Gaussian3DParam< Type >, casacore::Gaussian3DParam< AutoDiff< T > >, casacore::Gaussian3DParam< T >, casacore::CompoundParam< T >, casacore::CompoundParam< casacore::AutoDiff< Double > >, casacore::CompoundParam< AutoDiff< T > >, casacore::CombiParam< T >, casacore::CombiParam< AutoDiff< T > >, casacore::SPolynomialParam< T >, casacore::HyperPlaneParam< T >, casacore::HyperPlaneParam< AutoDiff< T > >, casacore::ConstantNDParam< T >, casacore::ConstantNDParam< AutoDiff< T > >, casacore::CompiledParam< T >, casacore::FunctionWrapper< T >, casacore::SincParam< T >, casacore::UnaryParam< T >, casacore::DiracDParam< T >, casacore::PoissonParam< T >, casacore::PoissonParam< AutoDiff< T > >, casacore::KaiserBParam< T >, casacore::GNoiseParam< T >, casacore::Function1D< T, U >, casacore::Function1D< Domain, Range >, casacore::Function1D< Double >, casacore::Function1D< AutoDiff< T > >, casacore::Function1D< casacore::Float, casacore::Float >, casacore::Function1D< T >, casacore::Function1D< Double, Double >, casacore::Function1D< AutoDiffA< T > >, casacore::Function1D< casacore::Float, casacore::casacore::Array< casacore::Float > >, and casacore::Function1D< casacore::casacore::AutoDiff< casacore::Float > >.
Referenced by casacore::Function< Type >::operator()().
|
inline |
Returns the number of parameters.
Definition at line 238 of file Function.h.
Referenced by casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >::coefficient(), casacore::ChebyshevParam< AutoDiffA< T > >::getCoefficient(), casacore::ChebyshevParam< AutoDiffA< T > >::nCoefficients(), and casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >::setCoefficient().
|
inlinevirtual |
Evaluate this function object at x
or at x, y
.
The length of x
must be greater than or equal to ndim()
.
Definition at line 254 of file Function.h.
|
inlinevirtual |
Definition at line 256 of file Function.h.
|
virtual |
|
inlinevirtual |
Definition at line 259 of file Function.h.
|
virtual |
|
virtual |
|
inline |
Manipulate the nth parameter (0-based) with no index check.
Definition at line 246 of file Function.h.
|
inline |
Definition at line 248 of file Function.h.
|
inline |
Return the parameter interface.
Definition at line 280 of file Function.h.
|
inline |
Definition at line 281 of file Function.h.
|
inline |
Definition at line 287 of file Function.h.
|
inline |
|
virtual |
get/set the function mode.
These provide an interface to function-specific configuration or state that controls how the function calculates its values but otherwise does not qualify as a parameter. Some part of the state, for example, might have a type different from that of T. The state is passed as fields of a record, mode–the names, types and values of which are specific to the implementing function and should be documented in the implementing class. It is recommended that all possible inputs passed to this function via setMode() be considered optional such that if the record omits a legal field, that part of the state is left unchanged. Fields not recognized by the implementing class should be ignored. An exception should be thrown if a recognized field contains illegal data. The default implementations for both getMode() and setMode() ignore the input record.
Reimplemented in casacore::ChebyshevParamModeImpl_PSA< AutoDiffA< T > >, casacore::ChebyshevParamModeImpl_PS< AutoDiff< T > >, casacore::ChebyshevParamModeImpl< T >, and casacore::SimButterworthBandpass< T >.
|
inline |
Definition at line 296 of file Function.h.
|
mutableprotected |
Aid for non-contiguous argument storage.
Definition at line 342 of file Function.h.
Referenced by casacore::Function< Type >::argp().
|
mutableprotected |
Indicate that parameters are expected to be locked from changing.
Definition at line 346 of file Function.h.
Referenced by casacore::Function< Type >::lockParam(), casacore::Function< Type >::mask(), casacore::Function< Type >::operator[](), and casacore::Function< Type >::unlockParam().
|
protected |
The parameters and masks.
Definition at line 340 of file Function.h.
Referenced by casacore::Sinusoid1DParam< AutoDiff< T > >::amplitude(), casacore::Gaussian1DParam< AutoDiff< T > >::center(), casacore::Lorentzian1DParam< AutoDiff< T > >::center(), casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >::coefficient(), casacore::EvenPolynomialParam< AutoDiff< T > >::coefficient(), casacore::PolynomialParam< casacore::casacore::AutoDiff< casacore::Float > >::coefficient(), casacore::OddPolynomialParam< AutoDiff< T > >::coefficient(), casacore::SimButterworthBandpass< T >::getCenter(), casacore::ChebyshevParam< AutoDiffA< T > >::getCoefficient(), casacore::SimButterworthBandpass< T >::getMaxCutoff(), casacore::SimButterworthBandpass< T >::getMinCutoff(), casacore::SimButterworthBandpass< T >::getPeak(), casacore::Lorentzian1DParam< AutoDiff< T > >::height(), casacore::Gaussian1DParam< AutoDiff< T > >::height(), casacore::Function< Type >::mask(), casacore::Function< Type >::nparameters(), casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >::operator!=(), casacore::EvenPolynomialParam< AutoDiff< T > >::operator!=(), casacore::OddPolynomialParam< AutoDiff< T > >::operator!=(), casacore::PolynomialParam< casacore::casacore::AutoDiff< casacore::Float > >::operator!=(), casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >::operator==(), casacore::EvenPolynomialParam< AutoDiff< T > >::operator==(), casacore::OddPolynomialParam< AutoDiff< T > >::operator==(), casacore::PolynomialParam< casacore::casacore::AutoDiff< casacore::Float > >::operator==(), casacore::Function< Type >::operator[](), casacore::EvenPolynomialParam< AutoDiff< T > >::order(), casacore::PolynomialParam< casacore::casacore::AutoDiff< casacore::Float > >::order(), casacore::OddPolynomialParam< AutoDiff< T > >::order(), casacore::ChebyshevParam< AutoDiffA< T > >::order(), casacore::Function< Type >::parameters(), casacore::Sinusoid1DParam< AutoDiff< T > >::period(), casacore::Function< Type >::print(), casacore::Sinusoid1DParam< AutoDiff< T > >::setAmplitude(), casacore::SimButterworthBandpass< T >::setCenter(), casacore::Gaussian1DParam< AutoDiff< T > >::setCenter(), casacore::Lorentzian1DParam< AutoDiff< T > >::setCenter(), casacore::PowerLogarithmicPolynomialParam< AutoDiff< T > >::setCoefficient(), casacore::EvenPolynomialParam< AutoDiff< T > >::setCoefficient(), casacore::PolynomialParam< casacore::casacore::AutoDiff< casacore::Float > >::setCoefficient(), casacore::OddPolynomialParam< AutoDiff< T > >::setCoefficient(), casacore::Gaussian1DParam< AutoDiff< T > >::setHeight(), casacore::Lorentzian1DParam< AutoDiff< T > >::setHeight(), casacore::SimButterworthBandpass< T >::setMaxCutoff(), casacore::SimButterworthBandpass< T >::setMinCutoff(), casacore::SimButterworthBandpass< T >::setPeak(), casacore::Sinusoid1DParam< AutoDiff< T > >::setPeriod(), casacore::Lorentzian1DParam< AutoDiff< T > >::setWidth(), casacore::Gaussian1DParam< AutoDiff< T > >::setWidth(), casacore::Sinusoid1DParam< AutoDiff< T > >::setX0(), casacore::Gaussian1DParam< AutoDiff< T > >::width(), casacore::Lorentzian1DParam< AutoDiff< T > >::width(), and casacore::Sinusoid1DParam< AutoDiff< T > >::x0().
|
mutableprotected |
Indicate parameter written.
Definition at line 344 of file Function.h.
Referenced by casacore::Function< Type >::mask(), casacore::Function< Type >::operator[](), casacore::Function< Type >::parameters(), and casacore::Function< Type >::parsetp().