bpp-core3  3.0.0
bpp::FirstOrderDerivableWrapper 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::FirstOrderDerivableWrapper:
+ Collaboration diagram for bpp::FirstOrderDerivableWrapper:

Public Member Functions

 FirstOrderDerivableWrapper (std::shared_ptr< FirstOrderDerivable > function)
 
void enableFirstOrderDerivatives (bool yn)
 Tell if derivatives must be computed. More...
 
bool enableFirstOrderDerivatives () const
 Tell if derivatives must be computed. More...
 
double getFirstOrderDerivative (const std::string &variable) const
 Get the derivative of the function at the current point. More...
 
bool hasParameter (const std::string &name) const override
 Tell if there is a parameter with specified name. More...
 
void setParameters (const ParameterList &parameters) override
 Set the point where the function must be computed. More...
 
const ParameterListgetParameters () const override
 Get all parameters available. More...
 
const Parameterparameter (const std::string &name) const override
 Get the parameter with specified name. More...
 
double getValue () const override
 Get the value of the function at the current point. More...
 
double f (const ParameterList &parameters) override
 Get the value of the function according to a given set of parameters. More...
 
double getParameterValue (const std::string &name) const override
 Get the value for parameter of name 'name'. More...
 
void setAllParametersValues (const ParameterList &parameters) override
 Set the parameters values to be equals to those of parameters. More...
 
void setParameterValue (const std::string &name, double value) override
 Set the value of parameter with name name to be equal to value. More...
 
void setParametersValues (const ParameterList &parameters) override
 Update the parameters from parameters. More...
 
bool matchParametersValues (const ParameterList &parameters) override
 Update the parameters from parameters. More...
 
void removeConstraint (const std::string &name) override
 Remove the constraint associated with one parameter, if any. More...
 
void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint) override
 Set/Change the constraint associated with one parameter. More...
 
size_t getNumberOfParameters () const override
 Get the number of parameters. More...
 
void setNamespace (const std::string &prefix) override
 Set the namespace for the parameter names. More...
 
std::string getNamespace () const override
 
std::string getParameterNameWithoutNamespace (const std::string &name) const override
 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...
 
FirstOrderDerivableclone () const =0
 Create a copy of this object and send a pointer to it. More...
 
virtual double df (const std::string &variable, const ParameterList &parameters)
 Get the value of the first derivative of the function according to a given set of parameters. More...
 

Protected Member Functions

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

Protected Attributes

std::shared_ptr< FunctionInterfacefunction_
 

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 344 of file Functions.h.

Constructor & Destructor Documentation

◆ FirstOrderDerivableWrapper()

bpp::FirstOrderDerivableWrapper::FirstOrderDerivableWrapper ( std::shared_ptr< FirstOrderDerivable function)
inline

Definition at line 349 of file Functions.h.

Member Function Documentation

◆ clone() [1/2]

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

Referenced by bpp::FirstOrderDerivable::~FirstOrderDerivable(), and bpp::SecondOrderDerivable::~SecondOrderDerivable().

◆ clone() [2/2]

◆ df()

virtual double bpp::FirstOrderDerivable::df ( const std::string &  variable,
const ParameterList parameters 
)
inlinevirtualinherited

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

Parameters
variableThe name of the $ x $ variable in $ \frac{df}{dx} $.
parametersThe parameter set to pass to the function.
Returns
The value of the function with the given parameter set.
Exceptions
ExceptionIf an error occured.

Definition at line 138 of file Functions.h.

References bpp::FunctionInterface::setParameters().

◆ enableFirstOrderDerivatives() [1/2]

void bpp::FirstOrderDerivableWrapper::enableFirstOrderDerivatives ( bool  yn)
inlinevirtual

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::FirstOrderDerivable.

Definition at line 353 of file Functions.h.

◆ enableFirstOrderDerivatives() [2/2]

bool bpp::FirstOrderDerivableWrapper::enableFirstOrderDerivatives ( ) const
inlinevirtual

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::FirstOrderDerivable.

Definition at line 358 of file Functions.h.

◆ f()

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

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::FunctionInterface.

Reimplemented in bpp::InfinityFunctionWrapper, and bpp::AbstractNumericalDerivative.

Definition at line 272 of file Functions.h.

◆ getFirstOrderDerivative()

double bpp::FirstOrderDerivableWrapper::getFirstOrderDerivative ( const std::string &  variable) const
inlinevirtual

Get the derivative of the function at the current point.

Parameters
variableThe name of the $ x $ variable in $ \frac{df}{dx} $.
Returns
The value of the function.
Exceptions
ExceptionIf no point is specified or if an error occured.

Implements bpp::FirstOrderDerivable.

Definition at line 363 of file Functions.h.

◆ getNamespace()

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

Implements bpp::Parametrizable.

Definition at line 322 of file Functions.h.

◆ getNumberOfParameters()

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

Get the number of parameters.

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

Implements bpp::Parametrizable.

Definition at line 312 of file Functions.h.

◆ getParameterNameWithoutNamespace()

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

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 327 of file Functions.h.

◆ getParameters()

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

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 257 of file Functions.h.

◆ getParameters_()

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

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 333 of file Functions.h.

◆ getParameterValue()

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

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 277 of file Functions.h.

◆ getValue()

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

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::FunctionInterface.

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

Definition at line 267 of file Functions.h.

◆ hasParameter()

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

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 247 of file Functions.h.

◆ matchParametersValues()

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

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, and bpp::AbstractNumericalDerivative.

Definition at line 297 of file Functions.h.

◆ parameter()

const Parameter& bpp::FunctionWrapper::parameter ( const std::string &  name) const
inlineoverridevirtualinherited

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 262 of file Functions.h.

◆ removeConstraint()

void bpp::FunctionWrapper::removeConstraint ( const std::string &  name)
inlineoverridevirtualinherited

Remove the constraint associated with one parameter, if any.

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

Implements bpp::Parametrizable.

Definition at line 302 of file Functions.h.

◆ setAllParametersValues()

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

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, and bpp::AbstractNumericalDerivative.

Definition at line 282 of file Functions.h.

◆ setConstraint()

void bpp::FunctionWrapper::setConstraint ( const std::string &  name,
std::shared_ptr< ConstraintInterface constraint 
)
inlineoverridevirtualinherited

Set/Change the constraint associated with one parameter.

Parameters
nameThe name of the parameter to look for.
constraintA pointer to the constraint (may be null)
Exceptions
ParameterNotFoundExceptionif no parameter with this name is found.

Implements bpp::Parametrizable.

Definition at line 307 of file Functions.h.

◆ setNamespace()

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

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 317 of file Functions.h.

◆ setParameters()

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

Set the point where the function must be computed.

Parameters
parametersThe parameter set to pass to the function.

Implements bpp::FunctionInterface.

Reimplemented in bpp::InfinityFunctionWrapper, and bpp::AbstractNumericalDerivative.

Definition at line 252 of file Functions.h.

◆ setParametersValues()

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

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, and bpp::AbstractNumericalDerivative.

Definition at line 292 of file Functions.h.

◆ setParameterValue()

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

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, and bpp::AbstractNumericalDerivative.

Definition at line 287 of file Functions.h.

Member Data Documentation

◆ function_

std::shared_ptr<FunctionInterface> bpp::FunctionWrapper::function_
protectedinherited

Definition at line 235 of file Functions.h.

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


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