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

Public Member Functions

 DerivableFirstOrderWrapper (DerivableFirstOrder *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
 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...
 
DerivableFirstOrderclone () 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_ ()
 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 369 of file Functions.h.

Constructor & Destructor Documentation

◆ DerivableFirstOrderWrapper()

bpp::DerivableFirstOrderWrapper::DerivableFirstOrderWrapper ( DerivableFirstOrder function)
inline

Definition at line 374 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::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=().

◆ clone() [2/2]

◆ df()

virtual double bpp::DerivableFirstOrder::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 173 of file Functions.h.

References bpp::DerivableFirstOrder::getFirstOrderDerivative(), and bpp::Function::setParameters().

◆ enableFirstOrderDerivatives() [1/2]

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

Tell if derivatives must be computed.

Returns
yes/no

Implements bpp::DerivableFirstOrder.

Definition at line 382 of file Functions.h.

References bpp::FunctionWrapper::function_.

Referenced by enableFirstOrderDerivatives().

◆ enableFirstOrderDerivatives() [2/2]

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

Tell if derivatives must be computed.

Parameters
ynyes/no

Implements bpp::DerivableFirstOrder.

Definition at line 377 of file Functions.h.

References enableFirstOrderDerivatives(), and bpp::FunctionWrapper::function_.

◆ f()

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

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 bpp::FunctionWrapper::function_.

◆ getFirstOrderDerivative()

double bpp::DerivableFirstOrderWrapper::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::DerivableFirstOrder.

Definition at line 387 of file Functions.h.

References bpp::FunctionWrapper::function_.

◆ getNamespace()

std::string bpp::FunctionWrapper::getNamespace ( ) const
inlinevirtualinherited
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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getNamespace().

◆ getNumberOfParameters()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getNumberOfParameters().

◆ getParameter()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getParameter().

◆ getParameterNameWithoutNamespace()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getParameterNameWithoutNamespace().

◆ getParameters()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getParameters().

◆ getParameters_()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getParameters_().

◆ getParameterValue()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::getParameterValue().

◆ getValue()

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

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 bpp::FunctionWrapper::function_, and bpp::Function::getValue().

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

◆ hasParameter()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::hasParameter().

◆ matchParametersValues()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::matchParametersValues().

◆ setAllParametersValues()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::setAllParametersValues().

◆ setNamespace()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::setNamespace().

◆ setParameters()

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

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 bpp::FunctionWrapper::function_, and bpp::Function::setParameters().

◆ setParametersValues()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::setParametersValues().

◆ setParameterValue()

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

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 bpp::FunctionWrapper::function_, and bpp::Parametrizable::setParameterValue().

Member Data Documentation

◆ function_

Function* bpp::FunctionWrapper::function_
protectedinherited

Definition at line 270 of file Functions.h.

Referenced by enableFirstOrderDerivatives(), bpp::DerivableSecondOrderWrapper::enableSecondOrderDerivatives(), bpp::FunctionWrapper::f(), getFirstOrderDerivative(), bpp::InfinityDerivableFirstOrderWrapper::getFirstOrderDerivative(), bpp::FunctionWrapper::getNamespace(), bpp::FunctionWrapper::getNumberOfParameters(), bpp::FunctionWrapper::getParameter(), bpp::FunctionWrapper::getParameterNameWithoutNamespace(), bpp::FunctionWrapper::getParameters(), bpp::FunctionWrapper::getParameters_(), bpp::FunctionWrapper::getParameterValue(), bpp::DerivableSecondOrderWrapper::getSecondOrderDerivative(), bpp::InfinityDerivableSecondOrderWrapper::getSecondOrderDerivative(), bpp::FunctionWrapper::getValue(), bpp::InfinityFunctionWrapper::getValue(), bpp::FunctionWrapper::hasParameter(), bpp::AbstractNumericalDerivative::matchParametersValues(), bpp::FunctionWrapper::matchParametersValues(), bpp::InfinityFunctionWrapper::matchParametersValues(), bpp::FunctionWrapper::operator=(), bpp::AbstractNumericalDerivative::setAllParametersValues(), bpp::FunctionWrapper::setAllParametersValues(), bpp::InfinityFunctionWrapper::setAllParametersValues(), bpp::FunctionWrapper::setNamespace(), bpp::AbstractNumericalDerivative::setParameters(), bpp::FunctionWrapper::setParameters(), bpp::InfinityFunctionWrapper::setParameters(), bpp::AbstractNumericalDerivative::setParametersValues(), bpp::FunctionWrapper::setParametersValues(), bpp::InfinityFunctionWrapper::setParametersValues(), bpp::AbstractNumericalDerivative::setParameterValue(), bpp::FunctionWrapper::setParameterValue(), and bpp::InfinityFunctionWrapper::setParameterValue().


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