Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LinearSumFunction Class Reference

#include <LinearSumFunction.h>

Inheritance diagram for LinearSumFunction:

Inheritance graph
[legend]
Collaboration diagram for LinearSumFunction:

Collaboration graph
[legend]
List of all members.

Detailed Description

A function that can be used with a fitter.

This function is a composite of other functions and computes the linear sum of them.

Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 24 of file LinearSumFunction.h.

Public Member Functions

virtual void addToComposite (FunctionBase *)
 Adds the function to the linear sum of functions.
virtual FunctionBaseclone () const
 Creates a new function object by copying an existing one.
virtual int count ()
 Returns the number of functions that are a part of this composite.
virtual double derivByParm (int i, double x) const
 Returns the function's derivative at the coordinate value x with respect to the i-th parameter.
void freeParmNames (std::vector< std::string > &names) const
virtual const std::vector<
double > & 
getParameters ()
 Returns the values of the parameters as a vector.
virtual bool hasDerivatives () const
 Returns true if function can calculate its partial derivatives.
virtual void initialParameters (const FunctionHelper *helper)
 Sets the FunctionHelper so that the function can calculate a reasonable set of initial parameter values.
virtual double integrate (double lower_limit, double upper_limit) const
 Returns the integral of the function from the lower limit to the higher limit.
virtual bool isComposite () const
 Returns true.
 LinearSumFunction (const LinearSumFunction &)
 The copy constructor.
 LinearSumFunction ()
 The default constructor.
const std::stringname () const
 Returns the name of the function.
virtual double operator() (const std::vector< double > &v) const
 The function call operator for multi-dimension coordinate variable.
virtual double operator() (double x) const
 The function call operator.
const std::vector< std::string > & parmNames () const
 Returns a reference to a vector of parameter names.
virtual void removeFromComposite (FunctionBase *)
 Removes the function from the linear sum of functions.
virtual void setParameters (const std::vector< double > &incr)
 Sets the parameter values.
virtual std::vector< double
>::const_iterator 
setParameters (std::vector< double >::const_iterator it)
 Sets the parameter values to the value pointed to by the iterator.
void setParmNames (const std::vector< std::string > &names)
 Sets the names of the parameters.
virtual int size () const
 Returns the number of parameters.

Protected Member Functions

virtual void initialize ()
 Initializes the function and parameter names.
virtual void resize ()
 Resizes the appropriate vectors maintained in this base class.
void setName (const char *)
 Sets the name of the function.

Protected Attributes

std::string m_name
 The name of the function.
std::vector< std::stringm_parm_names
 The names of the function parameters.
std::vector< double > m_parms
 The parameter values.

Private Types

typedef std::vector< FunctionBase * > FunctionList_t

Private Attributes

FunctionList_t m_functions


Member Typedef Documentation

typedef std::vector< FunctionBase * > LinearSumFunction::FunctionList_t [private]
 

Definition at line 29 of file LinearSumFunction.h.


Constructor & Destructor Documentation

LinearSumFunction::LinearSumFunction  ) 
 

The default constructor.

Definition at line 39 of file LinearSumFunction.cxx.

References initialize().

Referenced by clone().

LinearSumFunction::LinearSumFunction const LinearSumFunction  ) 
 

The copy constructor.

Makes a deep copy.

Definition at line 44 of file LinearSumFunction.cxx.

References initialize(), and m_functions.


Member Function Documentation

void LinearSumFunction::addToComposite FunctionBase  )  [virtual]
 

Adds the function to the linear sum of functions.

Reimplemented from FunctionBase.

Definition at line 162 of file LinearSumFunction.cxx.

References m_functions.

FunctionBase * LinearSumFunction::clone  )  const [virtual]
 

Creates a new function object by copying an existing one.

The implementation raises an assertion as this member function should be reimplemented in s derived class.

Note:
There's an implementation here to satisfy the SIP interface.

Reimplemented from FunctionBase.

Definition at line 60 of file LinearSumFunction.cxx.

References LinearSumFunction().

int LinearSumFunction::count  )  [virtual]
 

Returns the number of functions that are a part of this composite.

Reimplemented from FunctionBase.

Definition at line 137 of file LinearSumFunction.cxx.

References m_functions.

double LinearSumFunction::derivByParm int  i,
double  x
const [virtual]
 

Returns the function's derivative at the coordinate value x with respect to the i-th parameter.

Derived classes must implement this function.

Todo:
Provide a numeric method for doing this calculation that will be the default.
Derived classes should provide more efficient analytic method if available.

Bug:
Make this function pure when problem compiling python/FunctionWrap under Windows is solved.

Reimplemented from FunctionBase.

Definition at line 119 of file LinearSumFunction.cxx.

References m_functions, and size().

void LinearSumFunction::freeParmNames std::vector< std::string > &  names  )  const
 

const vector< double > & LinearSumFunction::getParameters  )  [virtual]
 

Returns the values of the parameters as a vector.

The function is non-const because a derived class may need to create the vector.

Reimplemented from FunctionBase.

Definition at line 93 of file LinearSumFunction.cxx.

References m_functions, and FunctionBase::m_parms.

bool FunctionBase::hasDerivatives  )  const [virtual, inherited]
 

Returns true if function can calculate its partial derivatives.

This base class implementation returns true. Derived class that can not calculate its partial derivatives should return false. This allows an application to not attempt to use a minimizer that requires derivatives to use this function.

Reimplemented in LogNormal.

Definition at line 124 of file FunctionBase.cxx.

void LinearSumFunction::initialize  )  [protected, virtual]
 

Initializes the function and parameter names.

Reimplemented from FunctionBase.

Definition at line 55 of file LinearSumFunction.cxx.

References FunctionBase::m_name.

Referenced by LinearSumFunction().

void LinearSumFunction::initialParameters const FunctionHelper helper  )  [virtual]
 

Sets the FunctionHelper so that the function can calculate a reasonable set of initial parameter values.

Reimplemented from FunctionBase.

Definition at line 207 of file LinearSumFunction.cxx.

double FunctionBase::integrate double  lower_limit,
double  upper_limit
const [virtual, inherited]
 

Returns the integral of the function from the lower limit to the higher limit.

As of now all the integration is done here numerically using the trapezoidal rule. Derived class may implement an analytical expression in place of this numerical method.

Definition at line 132 of file FunctionBase.cxx.

References FunctionBase::operator()().

bool LinearSumFunction::isComposite  )  const [virtual]
 

Returns true.

Reimplemented from FunctionBase.

Definition at line 157 of file LinearSumFunction.cxx.

const string & FunctionBase::name  )  const [inherited]
 

Returns the name of the function.

Definition at line 81 of file FunctionBase.cxx.

References FunctionBase::m_name.

Referenced by FunctionController::addFunctionRep(), FunctionProjectorXML::createElement(), FunctionController::createNTuple(), FuncParmRep::drawProjectedValues(), hippodraw::Python::export_FunctionBase(), FunctionController::functionNames(), FunctionProjector::getTitle(), FunctionProjector::getYLabel(), and parmNames().

double FunctionBase::operator() const std::vector< double > &  v  )  const [virtual, inherited]
 

The function call operator for multi-dimension coordinate variable.

Returns the value of the function at coordinate represented by v. The implementation in this base class uses the first element of the vector and calls operator () ( double ).

Reimplemented in FunctionWrap.

Definition at line 175 of file FunctionBase.cxx.

References FunctionBase::operator()().

double LinearSumFunction::operator() double  x  )  const [virtual]
 

The function call operator.

Reimplemented from FunctionBase.

Definition at line 194 of file LinearSumFunction.cxx.

References m_functions.

const vector< string > & LinearSumFunction::parmNames  )  const [virtual]
 

Returns a reference to a vector of parameter names.

Reimplemented from FunctionBase.

Definition at line 66 of file LinearSumFunction.cxx.

References m_functions, FunctionBase::m_parm_names, and FunctionBase::name().

void LinearSumFunction::removeFromComposite FunctionBase  )  [virtual]
 

Removes the function from the linear sum of functions.

Reimplemented from FunctionBase.

Definition at line 180 of file LinearSumFunction.cxx.

References m_functions.

void FunctionBase::resize  )  [protected, virtual, inherited]
 

Resizes the appropriate vectors maintained in this base class.

Derived classes should call this member function after initializing the m_parm_names data member, as the new size is taken from that data member's size.

Definition at line 71 of file FunctionBase.cxx.

References FunctionBase::m_parm_names, FunctionBase::m_parms, and FunctionBase::size().

Referenced by Quadratic2::initialize(), Quadratic::initialize(), PowerLaw::initialize(), LogNormal::initialize(), Linear::initialize(), Landau::initialize(), Gaussian::initialize(), FunctionWrap::initialize(), Exponential::initialize(), Erfc::initialize(), ConstantF::initialize(), Chi2Dist::initialize(), BrokenPowerLaw::initialize(), FunctionWrap::setParmNames(), and FunctionBase::setParmNames().

void FunctionBase::setName const char *   )  [protected, inherited]
 

Sets the name of the function.

Definition at line 66 of file FunctionBase.cxx.

References FunctionBase::m_name.

Referenced by FunctionWrap::setName().

void FunctionBase::setParameters const std::vector< double > &  incr  )  [virtual, inherited]
 

Sets the parameter values.

Derived classes should implement this function by invoking incrementValues ( vector< double >::const_iterator ) so that they correctly work with the LinearSumFunction class.

Definition at line 104 of file FunctionBase.cxx.

Referenced by hippodraw::Python::export_FunctionBase(), FunctionProjector::restoreParameters(), FunctionProjectorXML::setAttributes(), and FunctionProjector::setParameters().

vector< double >::const_iterator LinearSumFunction::setParameters std::vector< double >::const_iterator  it  )  [virtual]
 

Sets the parameter values to the value pointed to by the iterator.

Returns an iterator to a data element one past the last used data element.

Reimplemented from FunctionBase.

Definition at line 107 of file LinearSumFunction.cxx.

References m_functions.

void FunctionBase::setParmNames const std::vector< std::string > &  names  )  [inherited]
 

Sets the names of the parameters.

Reimplemented in FunctionWrap.

Definition at line 93 of file FunctionBase.cxx.

References FunctionBase::m_parm_names, and FunctionBase::resize().

int LinearSumFunction::size  )  const [virtual]
 

Returns the number of parameters.

Reimplemented from FunctionBase.

Definition at line 144 of file LinearSumFunction.cxx.

References m_functions.

Referenced by derivByParm().


Member Data Documentation

FunctionList_t LinearSumFunction::m_functions [private]
 

Definition at line 30 of file LinearSumFunction.h.

Referenced by addToComposite(), count(), derivByParm(), getParameters(), LinearSumFunction(), operator()(), parmNames(), removeFromComposite(), setParameters(), and size().

std::string FunctionBase::m_name [protected, inherited]
 

The name of the function.

Definition at line 105 of file FunctionBase.h.

Referenced by FunctionBase::FunctionBase(), Quadratic2::initialize(), Quadratic::initialize(), PowerLaw::initialize(), LogNormal::initialize(), initialize(), Linear::initialize(), Landau::initialize(), Gaussian::initialize(), Exponential::initialize(), Erfc::initialize(), ConstantF::initialize(), Chi2Dist::initialize(), BrokenPowerLaw::initialize(), FunctionBase::name(), and FunctionBase::setName().

std::vector<std::string> FunctionBase::m_parm_names [protected, inherited]
 

The names of the function parameters.

Definition at line 108 of file FunctionBase.h.

Referenced by Quadratic2::initialize(), Quadratic::initialize(), PowerLaw::initialize(), LogNormal::initialize(), Linear::initialize(), Landau::initialize(), Gaussian::initialize(), Exponential::initialize(), Erfc::initialize(), ConstantF::initialize(), Chi2Dist::initialize(), BrokenPowerLaw::initialize(), parmNames(), FunctionBase::parmNames(), FunctionBase::resize(), FunctionWrap::setParmNames(), FunctionBase::setParmNames(), and FunctionBase::size().

std::vector< double > FunctionBase::m_parms [protected, inherited]
 

The parameter values.

Definition at line 111 of file FunctionBase.h.

Referenced by BrokenPowerLaw::BrokenPowerLaw(), Erfc::calcRed(), Chi2Dist::Chi2Dist(), ConstantF::ConstantF(), Gaussian::derivByMean(), Landau::derivByNorm(), Gaussian::derivByNorm(), Quadratic2::derivByParm(), PowerLaw::derivByParm(), Exponential::derivByParm(), Erfc::derivByParm(), Chi2Dist::derivByParm(), BrokenPowerLaw::derivByParm(), Landau::derivByPeak(), Landau::derivBySigma(), Gaussian::derivBySigma(), Erfc::Erfc(), Exponential::Exponential(), Gaussian::Gaussian(), getParameters(), FunctionBase::getParameters(), Quadratic2::initialParameters(), Quadratic::initialParameters(), PowerLaw::initialParameters(), LogNormal::initialParameters(), Linear::initialParameters(), Landau::initialParameters(), Gaussian::initialParameters(), Exponential::initialParameters(), Erfc::initialParameters(), ConstantF::initialParameters(), Chi2Dist::initialParameters(), BrokenPowerLaw::initialParameters(), Landau::Landau(), Linear::Linear(), LogNormal::LogNormal(), Quadratic2::operator()(), Quadratic::operator()(), PowerLaw::operator()(), LogNormal::operator()(), Linear::operator()(), Landau::operator()(), Gaussian::operator()(), Exponential::operator()(), Erfc::operator()(), ConstantF::operator()(), Chi2Dist::operator()(), BrokenPowerLaw::operator()(), PowerLaw::PowerLaw(), Quadratic::Quadratic(), Quadratic2::Quadratic2(), FunctionBase::resize(), and FunctionBase::setParameters().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3