SMILE  v2.5
Schwarzschild Modelling Interactive expLoratory Environment
Classes | Namespaces | Macros | Typedefs | Functions | Variables
utils.h File Reference

several mathematical, statistical, string formatting and error reporting routines More...

#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_bspline.h>
#include <gsl/gsl_rng.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Classes

class  smile::StringVariant
 The StringVariant class is a simple string-based variant implementation that allows the user to easily convert between simple numeric/string types. More...
 
class  smile::CSplineApprox
 Penalized linear least-square fitting problem. More...
 

Namespaces

 smile
 common namespace for all core SMILE classes, functions and variables
 

Macros

#define FUNCNAME   __FUNCTION__
 

Typedefs

typedef void smile::show_message_type (const std::string &origin, const std::string &message)
 a function that shows a given message string. More...
 

Functions

static void smile::my_error (const std::string &origin, const std::string &message)
 the interface routine for error reporting (redirects the call to my_error_ptr if it is defined)
 
static void smile::my_message (const std::string &origin, const std::string &message)
 the interface routine for message reporting (redirects the call to my_message_ptr if it is defined)
 
void smile::my_stderr_show_message (const std::string &origin, const std::string &message)
 default routine that dumps text messages to stderr More...
 
void smile::gsl_verbose_error_handler (const char *reason, const char *file, int line, int gsl_errno)
 error reporting routine which is invoked from inside GSL. More...
 
template<typename NumberType , typename ValueType >
NumberType smile::convertTo (ValueType val)
 a shorthand function to convert a string to a number
 
template<typename ValueType >
bool smile::convertToBool (ValueType val)
 a shorthand function to convert a string to a bool
 
template<typename ValueType >
std::string smile::convertToString (ValueType val)
 a shorthand function to convert a number to a string
 
static const char * smile::convertToString (bool val)
 a shorthand to convert a bool to a string
 
template<typename ValueType >
std::string smile::convertToString (ValueType val, unsigned int width)
 a shorthand function to convert a number to a string with a given precision
 
std::string smile::pp (double num, unsigned int width)
 Pretty-print: convert floating-point or integer numbers to a string of fixed length.
 
void smile::splitString (const std::string &src, const std::string &delim, std::vector< std::string > *result)
 routine that splits one line from a text file into several items. More...
 
bool smile::ends_with_str (const std::string &str, const std::string &end)
 routine that checks if a string ends with another string
 
bool smile::strings_equal (const std::string &str1, const std::string &str2)
 routine that compares two strings in a case-insensitive way
 
bool smile::strings_equal (const std::string &str1, const char *str2)
 overloaded routine that compares two strings in a case-insensitive way
 
void smile::randomize ()
 initialize random number generator using current time
 
double smile::getRandomNumber ()
 get a random number uniformly distributed in [0..1]
 
void smile::getNormalRandomNumbers (double *num1, double *num2)
 generates two random numbers with normal distribution (zero mean, dispersion=1)
 
void smile::getRandomUnitVector (double *x, double *y, double *z)
 generates 2d or 3d random vector with unit length; if z==NULL then create 2d vector, else 3d
 
void smile::createNonuniformGrid (size_t nnodes, double xmin, double xmax, bool zeroelem, std::vector< double > *grid)
 generates a grid with exponentially growing spacing. More...
 
void smile::createAlmostUniformGrid (const std::vector< double > &srcpoints, size_t minbin, size_t *gridsize, std::vector< double > *grid)
 creates an almost uniform grid so that each bin contains at least minbin points from input array. More...
 
double smile::findRoot (gsl_function *F, double xlower, double xupper, double xdefault=0, double reltoler=1e-8)
 wrapper for GSL root solver running multiple iterations until the convergence is achieved. More...
 
double smile::findMin (gsl_function *F, double xlower, double xupper, double xinit, double reltoler=1e-8)
 wrapper for GSL minimization routine to find local minimum enclosed between xlower < xinit < xupper. More...
 
double smile::findMinGuess (gsl_function *F, double xlower, double xupper, double reltoler=1e-8)
 wrapper for GSL minimization routine to find local minimum enclosed between xlower < xupper. More...
 
double smile::gsl_spline_evalx (const gsl_spline *spline, double x, gsl_interp_accel *a)
 modified functions for spline evaluation that extrapolate last segment linearly beyond the definition region
 
double smile::gsl_spline_eval_derivx (const gsl_spline *spline, double x, gsl_interp_accel *a)
 
double smile::gsl_spline_eval_deriv2x (const gsl_spline *spline, double x, gsl_interp_accel *a)
 
void smile::cspline_eval_all (const gsl_spline *spline, double x, double *val, double *der, double *der2)
 convenience function that evaluates cubic spline value, derivative and 2nd derivative at once (faster than doing it separately)
 
bool smile::check_spline_monotonic (const gsl_spline *spline)
 check if a cubic spline is everywhere monotonic
 
gsl_spline * smile::copyspline (const gsl_spline *src)
 create a copy of a spline by allocating new memory to all internal arrays and copying their data
 

Variables

const gsl_interp_type * smile::gsl_interp_ccspline
 a variant of cubic spline with given values of first derivative at endpoints. More...
 

Detailed Description

several mathematical, statistical, string formatting and error reporting routines

Author
EV
Date
2009-2014