bpp-core3  3.0.0
bpp::FunctionWrapper Class Referenceabstract

General class that wraps a function into another one. This class is meant to be derivated and just provides a general framework. More...

#include <Bpp/Numeric/Function/Functions.h>

+ Inheritance diagram for bpp::FunctionWrapper:
+ Collaboration diagram for bpp::FunctionWrapper:

Public Member Functions

 FunctionWrapper (Function *function)
 
 FunctionWrapper (const FunctionWrapper &fw)
 
FunctionWrapperoperator= (const FunctionWrapper &fw)
 
bool hasParameter (const std::string &name) const
 Tell if there is a parameter with specified name. More...
 
void setParameters (const ParameterList &parameters)
 Set the point where the function must be computed. More...
 
const ParameterListgetParameters () const
 Get all parameters available. More...
 
const ParametergetParameter (const std::string &name) const
 Get the parameter with specified name. More...
 
double getValue () const
 Get the value of the function at the current point. More...
 
double f (const ParameterList &parameters)
 Get the value of the function according to a given set of parameters. More...
 
double getParameterValue (const std::string &name) const
 Get the value for parameter of name 'name'. More...
 
void setAllParametersValues (const ParameterList &parameters)
 Set the parameters values to be equals to those of parameters. More...
 
void setParameterValue (const std::string &name, double value)
 Set the value of parameter with name name to be equal to value. More...
 
void setParametersValues (const ParameterList &parameters)
 Update the parameters from parameters. More...
 
bool matchParametersValues (const ParameterList &parameters)
 Update the parameters from parameters. More...
 
size_t getNumberOfParameters () const
 Get the number of parameters. More...
 
void setNamespace (const std::string &prefix)
 Set the namespace for the parameter names. More...
 
std::string getNamespace () const
 
std::string getParameterNameWithoutNamespace (const std::string &name) const
 Resolves a parameter name according to the current namespace. More...
 
virtual Clonableclone () const =0
 Create a copy of this object and send a pointer to it. More...
 

Protected Member Functions

ParameterListgetParameters_ ()
 Get all parameters available. More...
 

Protected Attributes

Functionfunction_
 

Detailed Description

General class that wraps a function into another one. This class is meant to be derivated and just provides a general framework.

Definition at line 266 of file Functions.h.

Constructor & Destructor Documentation

◆ FunctionWrapper() [1/2]

bpp::FunctionWrapper::FunctionWrapper ( Function function)
inline

Definition at line 273 of file Functions.h.

◆ FunctionWrapper() [2/2]

bpp::FunctionWrapper::FunctionWrapper ( const FunctionWrapper fw)
inline

Definition at line 274 of file Functions.h.

Member Function Documentation

◆ clone()

virtual Clonable* bpp::Clonable::clone ( ) const
pure virtualinherited

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implemented in bpp::TransformedParameter, bpp::MultipleDiscreteDistribution, bpp::DiscreteDistribution, bpp::ParameterListener, bpp::BppNumberI, bpp::HmmLikelihood, bpp::HmmEmissionProbabilities, bpp::Optimizer, bpp::OptimizationStopCondition, bpp::DerivableSecondOrder, bpp::DerivableFirstOrder, bpp::AbstractNumericalDerivative, bpp::Constraint, bpp::OutputStream, bpp::PlaceboTransformedParameter, bpp::IntervalTransformedParameter, bpp::RTransformedParameter, bpp::Table< T >, bpp::PrincipalComponentAnalysis, bpp::DualityDiagram, bpp::CorrespondenceAnalysis, bpp::ContingencyTableTest, bpp::Range< T >, bpp::UniformDiscreteDistribution, bpp::TruncatedExponentialDiscreteDistribution, bpp::Simplex, bpp::SimpleDiscreteDistribution, bpp::MixtureOfDiscreteDistributions, bpp::InvariantMixedDiscreteDistribution, bpp::GaussianDiscreteDistribution, bpp::GammaDiscreteDistribution, bpp::ExponentialDiscreteDistribution, bpp::DirichletDiscreteDistribution, bpp::ConstantDistribution, bpp::BetaDiscreteDistribution, bpp::ParametrizableCollection< N >, bpp::ParameterList, bpp::Parameter, bpp::ParameterEvent, bpp::BppUnsignedInteger, bpp::BppInteger, bpp::BppDouble, bpp::Number< T >, bpp::Number< double >, bpp::Number< int >, bpp::Number< unsigned int >, bpp::BppNotANumber, bpp::LinearMatrix< Scalar >, bpp::ColMatrix< Scalar >, bpp::RowMatrix< Scalar >, bpp::RowMatrix< double >, bpp::RowMatrix< Real >, bpp::RescaledHmmLikelihood, bpp::LowMemoryRescaledHmmLikelihood, bpp::LogsumHmmLikelihood, bpp::FullHmmTransitionMatrix, bpp::AutoCorrelationTransitionMatrix, bpp::TwoPointsNumericalDerivative, bpp::ThreePointsNumericalDerivative, bpp::SimpleNewtonMultiDimensions, bpp::SimpleMultiDimensions, bpp::ReparametrizationDerivableSecondOrderWrapper, bpp::ReparametrizationDerivableFirstOrderWrapper, bpp::ReparametrizationFunctionWrapper, bpp::PowellMultiDimensions, bpp::PowellMultiDimensions::PMDStopCondition, bpp::FunctionStopCondition, bpp::ParametersStopCondition, bpp::NegativeOperator, bpp::MathOperator, bpp::FunctionOperator< F >, bpp::ConstantOperator, bpp::ComputationTree, bpp::BinaryOperator, bpp::NewtonOneDimension, bpp::NewtonBacktrackOneDimension, bpp::NewtonBacktrackOneDimension::NBODStopCondition, bpp::MetaOptimizer, bpp::MetaOptimizerInfos, bpp::GoldenSectionSearch, bpp::GoldenSectionSearch::GSSStopCondition, bpp::TestFunction, bpp::InfinityDerivableSecondOrderWrapper, bpp::InfinityDerivableFirstOrderWrapper, bpp::InfinityFunctionWrapper, bpp::FivePointsNumericalDerivative, bpp::DownhillSimplexMethod, bpp::DownhillSimplexMethod::DSMStopCondition, bpp::DirectionFunction, bpp::ConjugateGradientMultiDimensions, bpp::BrentOneDimension, bpp::BrentOneDimension::BODStopCondition, bpp::BfgsMultiDimensions, bpp::DataTable, bpp::IntervalConstraint, bpp::AutoParameter, bpp::AliasParameterListener, bpp::StdErr, bpp::StdOut, bpp::StlOutputStreamWrapper, bpp::StlOutputStream, bpp::NullOutputStream, bpp::RGBColor, bpp::Point2D< T >, bpp::Font, bpp::GlobalGraph, bpp::AssociationTreeGraphImplObserver< N, E, TreeGraphImpl >, bpp::AssociationGraphImplObserver< N, E, GraphImpl >, bpp::AssociationGraphImplObserver< N, E, DAGraphImpl >, bpp::AssociationGraphImplObserver< N, E, TreeGraphImpl >, bpp::AssociationDAGraphImplObserver< N, E, DAGraphImpl >, bpp::BppVector< T >, bpp::BppString, and bpp::BppBoolean.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::LogsumHmmLikelihood::LogsumHmmLikelihood(), and bpp::LogsumHmmLikelihood::operator=().

◆ f()

double bpp::FunctionWrapper::f ( const ParameterList parameters)
inlinevirtual

Get the value of the function according to a given set of parameters.

Parameters
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Reimplemented from bpp::Function.

Reimplemented in bpp::InfinityFunctionWrapper.

Definition at line 307 of file Functions.h.

References bpp::Function::f(), and function_.

◆ getNamespace()

std::string bpp::FunctionWrapper::getNamespace ( ) const
inlinevirtual
Returns
The current namespace used. This is an empty string if no namespace is currently defined.

Implements bpp::Parametrizable.

Definition at line 347 of file Functions.h.

References function_, and bpp::Parametrizable::getNamespace().

◆ getNumberOfParameters()

size_t bpp::FunctionWrapper::getNumberOfParameters ( ) const
inlinevirtual

Get the number of parameters.

See also
getNumberOfIndependentParameters If some parameters are aliased.
Returns
The number of parameters.

Implements bpp::Parametrizable.

Definition at line 337 of file Functions.h.

References function_, and bpp::Parametrizable::getNumberOfParameters().

◆ getParameter()

const Parameter& bpp::FunctionWrapper::getParameter ( const std::string &  name) const
inlinevirtual

Get the parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
The parameter with given name.
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implements bpp::Parametrizable.

Definition at line 297 of file Functions.h.

References function_, and bpp::Parametrizable::getParameter().

◆ getParameterNameWithoutNamespace()

std::string bpp::FunctionWrapper::getParameterNameWithoutNamespace ( const std::string &  name) const
inlinevirtual

Resolves a parameter name according to the current namespace.

Returns
The parameter name without the namespace prefix, if any.

Implements bpp::Parametrizable.

Definition at line 352 of file Functions.h.

References function_, and bpp::Parametrizable::getParameterNameWithoutNamespace().

◆ getParameters()

const ParameterList& bpp::FunctionWrapper::getParameters ( ) const
inlinevirtual

Get all parameters available.

See also
getIndependentParameters if some parameters are aliased.
Returns
A list with all parameters available.

Implements bpp::Parametrizable.

Definition at line 292 of file Functions.h.

References function_, and bpp::Parametrizable::getParameters().

◆ getParameters_()

ParameterList& bpp::FunctionWrapper::getParameters_ ( )
inlineprotectedvirtual

Get all parameters available.

See also
getIndependentParameters if some parameters are aliased.
Returns
A list with all parameters available.

Implements bpp::Parametrizable.

Definition at line 358 of file Functions.h.

References function_, and bpp::Parametrizable::getParameters_().

◆ getParameterValue()

double bpp::FunctionWrapper::getParameterValue ( const std::string &  name) const
inlinevirtual

Get the value for parameter of name 'name'.

Parameters
nameThe name of the parameter.
Returns
the value of parameter name.

Implements bpp::Parametrizable.

Definition at line 312 of file Functions.h.

References function_, and bpp::Parametrizable::getParameterValue().

◆ getValue()

double bpp::FunctionWrapper::getValue ( ) const
inlinevirtual

Get the value of the function at the current point.

Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::Function.

Reimplemented in bpp::TwoPointsNumericalDerivative, bpp::ThreePointsNumericalDerivative, and bpp::InfinityFunctionWrapper.

Definition at line 302 of file Functions.h.

References function_, and bpp::Function::getValue().

Referenced by bpp::AbstractNumericalDerivative::f().

◆ hasParameter()

bool bpp::FunctionWrapper::hasParameter ( const std::string &  name) const
inlinevirtual

Tell if there is a parameter with specified name.

Parameters
nameThe name of the parameter to look for.
Returns
y/n.

Implements bpp::Parametrizable.

Definition at line 282 of file Functions.h.

References function_, and bpp::Parametrizable::hasParameter().

◆ matchParametersValues()

bool bpp::FunctionWrapper::matchParametersValues ( const ParameterList parameters)
inlinevirtual

Update the parameters from parameters.

Only common parameters with parameters will be updated.

Parameters
parametersA list of parameters.
Returns
True if at least one parameter value has been changed.
Exceptions
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implements bpp::Parametrizable.

Reimplemented in bpp::InfinityFunctionWrapper.

Definition at line 332 of file Functions.h.

References function_, and bpp::Parametrizable::matchParametersValues().

◆ operator=()

FunctionWrapper& bpp::FunctionWrapper::operator= ( const FunctionWrapper fw)
inline

Definition at line 275 of file Functions.h.

References function_.

Referenced by bpp::AbstractNumericalDerivative::operator=().

◆ setAllParametersValues()

void bpp::FunctionWrapper::setAllParametersValues ( const ParameterList parameters)
inlinevirtual

Set the parameters values to be equals to those of parameters.

The list must contain exactly the same parameters (ie same names) than the parameters available.

Parameters
parametersA list with all parameters.
Exceptions
ParameterNotFoundExceptionIf a some parameter in the list is not in params.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implements bpp::Parametrizable.

Reimplemented in bpp::InfinityFunctionWrapper.

Definition at line 317 of file Functions.h.

References function_, and bpp::Parametrizable::setAllParametersValues().

◆ setNamespace()

void bpp::FunctionWrapper::setNamespace ( const std::string &  prefix)
inlinevirtual

Set the namespace for the parameter names.

Parameters
prefixThe 'namespace', that is a prefix to add to all parameter names. If parameter names are already prefixed, the new prefix will be used instead.

Implements bpp::Parametrizable.

Definition at line 342 of file Functions.h.

References function_, and bpp::Parametrizable::setNamespace().

◆ setParameters()

void bpp::FunctionWrapper::setParameters ( const ParameterList parameters)
inlinevirtual

Set the point where the function must be computed.

Parameters
parametersThe parameter set to pass to the function.

Implements bpp::Function.

Reimplemented in bpp::InfinityFunctionWrapper.

Definition at line 287 of file Functions.h.

References function_, and bpp::Function::setParameters().

◆ setParametersValues()

void bpp::FunctionWrapper::setParametersValues ( const ParameterList parameters)
inlinevirtual

Update the parameters from parameters.

parameters must be a subset of all parameters available.

Parameters
parametersA list containing all parameters to update.
Exceptions
ParameterNotFoundExceptionIf a some parameter in params is not in the list.
ConstraintExceptionIf a value in parameters does not match the constraint in the corresponding parameter in the list.

Implements bpp::Parametrizable.

Reimplemented in bpp::InfinityFunctionWrapper.

Definition at line 327 of file Functions.h.

References function_, and bpp::Parametrizable::setParametersValues().

◆ setParameterValue()

void bpp::FunctionWrapper::setParameterValue ( const std::string &  name,
double  value 
)
inlinevirtual

Set the value of parameter with name name to be equal to value.

Parameters
namethe name of the parameter to set.
valueThe value of the parameter.
Exceptions
ParameterNotFoundExceptionIf no parameter in the list has the name name.
ConstraintExceptionIf value does not match the constraint associated to parameter name.

Implements bpp::Parametrizable.

Reimplemented in bpp::InfinityFunctionWrapper.

Definition at line 322 of file Functions.h.

References function_, and bpp::Parametrizable::setParameterValue().

Member Data Documentation

◆ function_


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