bpp-core3  3.0.0
bpp::NumCalcApplicationTools Class Reference

#include <Bpp/App/NumCalcApplicationTools.h>

Public Member Functions

 NumCalcApplicationTools ()
 
virtual ~NumCalcApplicationTools ()
 

Static Public Member Functions

static std::vector< int > seqFromString (const std::string &s, const std::string &delim=",", const std::string &seqdelim="-")
 Build a vector of integers as described by a string. More...
 
static std::vector< double > getVector (const std::string &desc)
 Build a vector of double from a structured text description. More...
 
static double getDefaultValue (const ParameterList &pl, const std::string &name, double x)
 Returns the value of the Parameter of the given name if it exists; otherwise returns the default value. More...
 
static ParameterGridgetParameterGrid (std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool warn=true)
 Design a parameter grid from input options. More...
 

Detailed Description

Definition at line 52 of file NumCalcApplicationTools.h.

Constructor & Destructor Documentation

◆ NumCalcApplicationTools()

bpp::NumCalcApplicationTools::NumCalcApplicationTools ( )

◆ ~NumCalcApplicationTools()

virtual bpp::NumCalcApplicationTools::~NumCalcApplicationTools ( )
virtual

Member Function Documentation

◆ getDefaultValue()

double NumCalcApplicationTools::getDefaultValue ( const ParameterList pl,
const std::string &  name,
double  x 
)
static

Returns the value of the Parameter of the given name if it exists; otherwise returns the default value.

Author
Laurent Gueguen
Parameters
plA parameter list to look in.
nameA string name
xA double value

Definition at line 118 of file NumCalcApplicationTools.cpp.

References bpp::Parameter::getName(), bpp::Parameter::getValue(), and bpp::ParameterList::size().

◆ getParameterGrid()

ParameterGrid * NumCalcApplicationTools::getParameterGrid ( std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  warn = true 
)
static

Design a parameter grid from input options.

Example:

grid.number_of_parameters=3
grid.parameter1.name=x
grid.parameter1.values=0.1,0.2,0.3,0.4,0.5
grid.parameter2.name=y
grid.parameter2.values=seq(from=0.1,to=0.5,step=0.1)
grid.parameter3.name=z
grid.parameter3.values=seq(from=0.1,to=0.5,size=5)
T to(const std::string &s)
Template to string conversion.
Definition: TextTools.h:208
Parameters
paramsThe attribute map where options may be found.
suffixA suffix to be applied to the parameter name.
suffixIsOptionalTell if the suffix is absolutely required.
warnTell if a warning must be sent in case the parameter is not found.
Returns
a parameter grid object.

Definition at line 130 of file NumCalcApplicationTools.cpp.

References bpp::ParameterGrid::addDimension(), bpp::ApplicationTools::getStringParameter(), and bpp::TextTools::toString().

◆ getVector()

vector< double > NumCalcApplicationTools::getVector ( const std::string &  desc)
static

Build a vector of double from a structured text description.

The syntax may be one of the following:

  • Specified values: 1.23, 2.34, 3.45, 4.56
  • Sequence macro: seq(from=1.23,to=2.45,step=0.1) or seq(from=1.23,to=2.45,size=5) The meaning of these to form is equivalent as the R function: The first one start from 1.23 and increment 0.1 until it reaches the 2.45 value, wheras the seocnd one will compute 3 values at equal distance from 1.23 and 2.45. the 'from' and 'to' values are included, except for the first syntax when the interval is not an exact multiple of the 'step' argument.
Author
Julien Dutheil
Parameters
descThe string to parse.
Returns
A vector containing the corresponding values as double.
Exceptions
ExceptionIf the syntax describing the set is not correct.

Definition at line 72 of file NumCalcApplicationTools.cpp.

References bpp::StringTokenizer::hasMoreToken(), bpp::KeyvalTools::multipleKeyvals(), bpp::StringTokenizer::nextToken(), bpp::NumConstants::TINY(), bpp::TextTools::toDouble(), and bpp::TextTools::toInt().

◆ seqFromString()

vector< int > NumCalcApplicationTools::seqFromString ( const std::string &  s,
const std::string &  delim = ",",
const std::string &  seqdelim = "-" 
)
static

Build a vector of integers as described by a string.

Build a vector of integers following a description like: "2, 5, 7-10, 4" => [2, 5, 7, 8, 9, 10, 4]

Author
Sylvain Gaillard
Parameters
sThe string to parse.
delimDelimiter between elements.
seqdelimDelimiter between min and max for a sequence.
Returns
A vector containing the integers

Definition at line 50 of file NumCalcApplicationTools.cpp.

References bpp::VectorTools::append(), bpp::VectorTools::seq(), and bpp::TextTools::toInt().


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