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

FunctionWrap Class Reference

#include <FunctionWrap.h>

Inheritance diagram for FunctionWrap:

Inheritance graph
[legend]
Collaboration diagram for FunctionWrap:

Collaboration graph
[legend]
List of all members.

Detailed Description

A wrapper class for FunctionBase.

This class allows one to implement in Python a derived class of FunctionBase.

Note:
This class needs Python 2.3 or later to be fully functional.
Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>
with a lot of help from

Author:
David Abrahams <dave@boost-consulting.com>

Definition at line 33 of file FunctionWrap.h.

Public Member Functions

virtual void addToComposite (FunctionBase *)
 Does nothing.
FunctionBaseclone () const
 Make copy of object, including copy of Python object.
virtual int count ()
 Returns 0.
double derivByParm (int, double) const
 FunctionWrap ()
 The default constructor.
 FunctionWrap (const FunctionWrap &)
 The copy constructor.
 FunctionWrap (const FunctionBase &base)
 Constructor.
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.
void initialize ()
void initialParameters (const FunctionHelper *)
 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 false.
const std::stringname () const
 Returns the name of the function.
double operator() (const std::vector< double > &) const
double operator() (double) const
virtual const std::vector<
std::string > & 
parmNames () const
 Returns a reference to a vector of parameter names.
virtual void removeFromComposite (FunctionBase *)
 Does nothing.
void setName (const std::string &name)
 Sets the name of the function.
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.
virtual void setParameters (const std::vector< double > &incr)
 Sets the parameter values.
void setParmNames (const std::vector< std::string > &names)
 Sets the names of the parameters and resizes the number of parameters available.
virtual int size () const
 Returns the number of parameters.
virtual ~FunctionWrap ()
 The destructor.

Protected Member Functions

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 Member Functions

template<class T>
boost::python::object get_owner (T *me) const
 Find the Python object that owns this object.

Private Attributes

boost::python::object invert_ownership
 The new ownership.


Constructor & Destructor Documentation

FunctionWrap::FunctionWrap const FunctionBase base  ) 
 

Constructor.

Definition at line 103 of file FunctionWrap.cxx.

FunctionWrap::FunctionWrap const FunctionWrap  ) 
 

The copy constructor.

Definition at line 109 of file FunctionWrap.cxx.

FunctionWrap::FunctionWrap  ) 
 

The default constructor.

Definition at line 97 of file FunctionWrap.cxx.

FunctionWrap::~FunctionWrap  )  [virtual]
 

The destructor.

Definition at line 115 of file FunctionWrap.cxx.


Member Function Documentation

void FunctionBase::addToComposite FunctionBase  )  [virtual, inherited]
 

Does nothing.

Derived classes that are a composite of functions should override this member function and add functions to the composite.

Reimplemented in LinearSumFunction.

Definition at line 160 of file FunctionBase.cxx.

Referenced by FunctionController::addFunctionRep(), and FunctionController::buildComposite().

FunctionBase * FunctionWrap::clone  )  const [virtual]
 

Make copy of object, including copy of Python object.

Reimplemented from FunctionBase.

Definition at line 140 of file FunctionWrap.cxx.

References get_owner(), and invert_ownership.

int FunctionBase::count  )  [virtual, inherited]
 

Returns 0.

Derived classes that are a composite of functions should override this member function to return the number of functions in the composite.

Reimplemented in LinearSumFunction.

Definition at line 168 of file FunctionBase.cxx.

Referenced by FunctionController::removeFunction().

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

Note:
This member function is only available with Python 2.3 or later.

Reimplemented from FunctionBase.

Definition at line 198 of file FunctionWrap.cxx.

References get_owner().

template<class T>
object FunctionWrap::get_owner T *  me  )  const [private]
 

Find the Python object that owns this object.

Definition at line 128 of file FunctionWrap.cxx.

Referenced by clone(), derivByParm(), initialize(), and operator()().

const vector< double > & FunctionBase::getParameters  )  [virtual, inherited]
 

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 in LinearSumFunction.

Definition at line 99 of file FunctionBase.cxx.

References FunctionBase::m_parms.

Referenced by FunctionProjectorXML::createElement(), FuncParmRep::drawProjectedValues(), hippodraw::Python::export_FunctionBase(), FunctionRep::parameters(), FunctionProjector::saveParameters(), and FunctionProjector::setParameters().

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 FunctionWrap::initialize  )  [virtual]
 

Note:
This function is only available for Python 2.3 or later.

Reimplemented from FunctionBase.

Definition at line 226 of file FunctionWrap.cxx.

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

Referenced by hippodraw::Python::export_FunctionBase().

void FunctionWrap::initialParameters const FunctionHelper  )  [virtual]
 

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

Reimplemented from FunctionBase.

Definition at line 282 of file FunctionWrap.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 FunctionBase::isComposite  )  const [virtual, inherited]
 

Returns false.

Derived classes that are a composite of functions should override this member function and return true.

Reimplemented in LinearSumFunction.

Definition at line 155 of file FunctionBase.cxx.

Referenced by FunctionController::addFunctionRep(), FunctionRep::isComposite(), FunctionController::removeFunction(), FunctionController::restoreParameters(), and FunctionController::saveParameters().

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 LinearSumFunction::parmNames().

double FunctionWrap::operator() const std::vector< double > &  x  )  const [virtual]
 

Note:
This function is only available for Python 2.3 or later.

Reimplemented from FunctionBase.

Definition at line 263 of file FunctionWrap.cxx.

References get_owner().

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

Note:
This function is only available for Python 2.3 or later.

Reimplemented from FunctionBase.

Definition at line 244 of file FunctionWrap.cxx.

References get_owner().

const vector< string > & FunctionBase::parmNames  )  const [virtual, inherited]
 

Returns a reference to a vector of parameter names.

Reimplemented in LinearSumFunction.

Definition at line 86 of file FunctionBase.cxx.

References FunctionBase::m_parm_names.

Referenced by FuncParmRep::drawProjectedValues(), hippodraw::Python::export_FunctionBase(), and FunctionRep::parmNames().

void FunctionBase::removeFromComposite FunctionBase  )  [virtual, inherited]
 

Does nothing.

Derived classes that are a composite of functions should override this member function and remove functions from the composite.

Reimplemented in LinearSumFunction.

Definition at line 164 of file FunctionBase.cxx.

Referenced by FunctionController::removeFunction().

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(), initialize(), Exponential::initialize(), Erfc::initialize(), ConstantF::initialize(), Chi2Dist::initialize(), BrokenPowerLaw::initialize(), 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 setName().

void FunctionWrap::setName const std::string name  ) 
 

Sets the name of the function.

Note:
We have this function here so that FunctionBase::setName can remain protected and yet the Boost.Python and SIP interfaces can call this public member function.

Definition at line 181 of file FunctionWrap.cxx.

References FunctionBase::setName().

Referenced by hippodraw::Python::export_FunctionBase().

vector< double >::const_iterator FunctionBase::setParameters std::vector< double >::const_iterator  it  )  [virtual, inherited]
 

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 in LinearSumFunction.

Definition at line 112 of file FunctionBase.cxx.

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

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().

void FunctionWrap::setParmNames const std::vector< std::string > &  names  ) 
 

Sets the names of the parameters and resizes the number of parameters available.

Reimplemented from FunctionBase.

Definition at line 188 of file FunctionWrap.cxx.

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

Referenced by hippodraw::Python::export_FunctionBase().

int FunctionBase::size  )  const [virtual, inherited]
 

Returns the number of parameters.

Reimplemented in LinearSumFunction.

Definition at line 150 of file FunctionBase.cxx.

References FunctionBase::m_parm_names.

Referenced by LogNormal::initialParameters(), Gaussian::initialParameters(), FunctionBase::resize(), FunctionProjectorXML::setAttributes(), and FunctionBase::setParameters().


Member Data Documentation

boost::python::object FunctionWrap::invert_ownership [private]
 

The new ownership.

Definition at line 40 of file FunctionWrap.h.

Referenced by clone().

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(), LinearSumFunction::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(), LinearSumFunction::parmNames(), FunctionBase::parmNames(), FunctionBase::resize(), 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(), LinearSumFunction::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