Manticore  Version 2.0alpha
Physics of Molecular Clouds
Classes | Functions | Variables
mutils Namespace Reference

MathUtils package. More...

Classes

class  CommandLine
 Command line options and arguments. More...
 
class  Exception
 MathUtils exception (base) class. More...
 
struct  integ_data_t
 
struct  Log
 Logging facility. More...
 

Functions

const char * Cform (const std::string &s)
 Converts input to well-defined type for stdio. More...
 
template<typename T >
T * Cform (T *p)
 Converts input to well-defined type for stdio. More...
 
double Cform (double i)
 Converts input to well-defined type for stdio. More...
 
unsigned long Cform (unsigned long long i)
 Converts input to well-defined type for stdio. More...
 
unsigned long Cform (unsigned long i)
 Converts input to well-defined type for stdio. More...
 
unsigned long Cform (unsigned i)
 Converts input to well-defined type for stdio. More...
 
long Cform (long long i)
 Converts input to well-defined type for stdio. More...
 
long Cform (long i)
 Converts input to well-defined type for stdio. More...
 
long Cform (int i)
 Converts input to well-defined type for stdio. More...
 
int Cform (unsigned char i)
 Converts input to well-defined type for stdio. More...
 
int Cform (char i)
 Converts input to well-defined type for stdio. More...
 
int cxxfclose (FILE *fp)
 Standardized fclose(). More...
 
FILE * cxxfopen (const std::string &file, const char *mode)
 Standardized fopen(). More...
 
template<typename... Args>
int cxxfprintf (FILE *f, Args &&... args)
 C fprintf() with type conversion (not safety). More...
 
template<typename... Args>
int cxxprintf (Args &&... args)
 C printf() with type conversion (not safety). More...
 
template<typename... Args>
int cxxsnprintf (char *buf, size_t len, Args &&... args)
 C snprintf() with type conversion (not safety). More...
 
void exitException (std::exception &ex, int status=EXIT_FAILURE)
 Exits program with exception message. Exits the program (with status) after displaying the exception ex. More...
 
static double hifn (double x)
 
static double hifn_r (double x, void *vdata)
 
double kgauss (double(*f)(double x), double a, double b, double err)
 
double kgauss2 (double(*f)(double x), double a, double b, double err)
 
double kgauss2_r (double(*f_r)(double x, void *), void *fdata, double a, double b, double err)
 
double kgauss_r (double(*f_r)(double x, void *), void *fdata, double a, double b, double err)
 
double kgauss_sub (double(*f)(double), double(*f_r)(double, void *), void *fdata, double a, double b, double c, double *err, int sqroot, int lev, double I0, int maxrecur, int paranoid)
 
double kgauss_sub (double(*f)(double x), double(*f_r)(double x, void *), void *fdata, double a, double b, double c, double *acc, int root, int lev, double I0, int maxrecur, int paranoid)
 
double ksqrtgauss (double(*f)(double), double a, double b, double c, double err)
 
double ksqrtgauss (double(*f)(double x), double a, double b, double c, double err)
 
double ksqrtgauss_r (double(*f_r)(double, void *), void *fdata, double a, double b, double c, double err)
 
double ksqrtgauss_r (double(*f_r)(double x, void *), void *fdata, double a, double b, double c, double err)
 
static double lofn (double x)
 
static double lofn_r (double x, void *vdata)
 
const std::string nullStr (1, 0)
 
void printException (std::exception &ex)
 Prints exception message. More...
 
const std::string siPrefixes ("YZEPTGMkhDdcmunpfazy")
 
template<typename R >
sqr (R x)
 

Variables

static double c_gl
 
static double(* func_gl )(double x)
 
std::string::size_type npos = std::string::npos
 
const std::map< char, const char * > siScaleMap
 

Detailed Description

MathUtils package.

Function Documentation

◆ Cform() [1/11]

const char* mutils::Cform ( const std::string &  s)
inline

Converts input to well-defined type for stdio.

Definition at line 222 of file Log.h.

Referenced by cxxfprintf(), cxxprintf(), and cxxsnprintf().

◆ Cform() [2/11]

template<typename T >
T* mutils::Cform ( T *  p)
inline

Converts input to well-defined type for stdio.

Definition at line 225 of file Log.h.

◆ Cform() [3/11]

double mutils::Cform ( double  i)
inline

Converts input to well-defined type for stdio.

Definition at line 228 of file Log.h.

◆ Cform() [4/11]

unsigned long mutils::Cform ( unsigned long long  i)
inline

Converts input to well-defined type for stdio.

Definition at line 231 of file Log.h.

◆ Cform() [5/11]

unsigned long mutils::Cform ( unsigned long  i)
inline

Converts input to well-defined type for stdio.

Definition at line 234 of file Log.h.

◆ Cform() [6/11]

unsigned long mutils::Cform ( unsigned  i)
inline

Converts input to well-defined type for stdio.

Definition at line 237 of file Log.h.

◆ Cform() [7/11]

long mutils::Cform ( long long  i)
inline

Converts input to well-defined type for stdio.

Definition at line 240 of file Log.h.

◆ Cform() [8/11]

long mutils::Cform ( long  i)
inline

Converts input to well-defined type for stdio.

Definition at line 243 of file Log.h.

◆ Cform() [9/11]

long mutils::Cform ( int  i)
inline

Converts input to well-defined type for stdio.

Definition at line 246 of file Log.h.

◆ Cform() [10/11]

int mutils::Cform ( unsigned char  i)
inline

Converts input to well-defined type for stdio.

Definition at line 249 of file Log.h.

◆ Cform() [11/11]

int mutils::Cform ( char  i)
inline

Converts input to well-defined type for stdio.

Definition at line 252 of file Log.h.

◆ cxxfclose()

int mutils::cxxfclose ( FILE *  fp)
inline

Standardized fclose().

Equivalent to <cstdio> fclose(), except that the call is ignored if fp is stdin, stdout or stderr.

Parameters
[in]fpFile stream pointer.

Definition at line 325 of file Log.h.

Referenced by mutils::Log::setStream().

◆ cxxfopen()

FILE* mutils::cxxfopen ( const std::string &  file,
const char *  mode 
)
inline

Standardized fopen().

Equivalent to <cstdio> fopen(), except:

  • the file name argument is a std::string
  • file names of "-" and "!" are interpreted as stdin/stdout and stderr, respectively.
Parameters
[in]fileFile name.
[in]modeFile mode.

Definition at line 311 of file Log.h.

Referenced by mutils::Log::setStream().

◆ cxxfprintf()

template<typename... Args>
int mutils::cxxfprintf ( FILE *  f,
Args &&...  args 
)
inline

C fprintf() with type conversion (not safety).

Parameters
[in]fOpen output file stream.
[in]argsInput arguments (beginning with format string).
Returns
Number of bytes successfully written, or a negative value on error.
Warning
This method defeats all compile-time format checking (alas).
See also
mutils::cxxprintf, mutils::xfprintf

Definition at line 284 of file Log.h.

References Cform().

Referenced by mutils::Log::message().

◆ cxxprintf()

template<typename... Args>
int mutils::cxxprintf ( Args &&...  args)
inline

C printf() with type conversion (not safety).

Wraps each argument in a Cform() call and passes them to printf(). This converts all signed integers to type long and all unsigned integers to type unsigned long, so that the format conversion applied to them must be %ld or %lu, respectively. Characters are converted to type int and hence should use either %c or %d. Both C-strings and C++ std::string can be given as arguments using the %s conversion. All the usual format qualifiers may also be used.

Parameters
[in]argsInput arguments (beginning with format string).
Returns
Number of bytes successfully written, or a negative value on error.
Warning
This method defeats all compile-time format checking (alas).
See also
mutils::xprintf

Definition at line 273 of file Log.h.

References Cform().

◆ cxxsnprintf()

template<typename... Args>
int mutils::cxxsnprintf ( char *  buf,
size_t  len,
Args &&...  args 
)
inline

C snprintf() with type conversion (not safety).

Parameters
[in]bufOutput buffer.
[in]lenBuffer length.
[in]argsInput arguments (beginning with format string).
Returns
Minimum required buffer size minus one, or a negative value on error.
Warning
This method defeats all compile-time format checking (alas).
See also
mutils::cxxprintf

Definition at line 297 of file Log.h.

References Cform().

◆ exitException()

void mutils::exitException ( std::exception &  ex,
int  status = EXIT_FAILURE 
)
inline

Exits program with exception message. Exits the program (with status) after displaying the exception ex.

Note
This method does not return.
Parameters
[in]exInput exception.
[in]statusExit status.
See also
printException()

Definition at line 208 of file Exception.h.

References mutils::Log::file, and printException().

◆ hifn()

static double mutils::hifn ( double  x)
static

Definition at line 33 of file kgauss.cc.

References c_gl, and func_gl.

Referenced by kgauss_sub().

◆ hifn_r()

static double mutils::hifn_r ( double  x,
void *  vdata 
)
static

Definition at line 50 of file kgauss.cc.

References mutils::integ_data_t::c, mutils::integ_data_t::fdata, and mutils::integ_data_t::func.

Referenced by kgauss_sub().

◆ kgauss()

double mutils::kgauss ( double(*)(double x)  f,
double  a,
double  b,
double  err 
)

Definition at line 384 of file kgauss.cc.

References kgauss_sub().

◆ kgauss2()

double mutils::kgauss2 ( double(*)(double x)  f,
double  a,
double  b,
double  err 
)

Definition at line 389 of file kgauss.cc.

References kgauss_sub().

◆ kgauss2_r()

double mutils::kgauss2_r ( double(*)(double x, void *)  f_r,
void *  fdata,
double  a,
double  b,
double  err 
)

Definition at line 418 of file kgauss.cc.

References kgauss_sub().

◆ kgauss_r()

double mutils::kgauss_r ( double(*)(double x, void *)  f_r,
void *  fdata,
double  a,
double  b,
double  err 
)

Definition at line 412 of file kgauss.cc.

References kgauss_sub().

Referenced by manticore::Graybody::Itot2().

◆ kgauss_sub() [1/2]

double mutils::kgauss_sub ( double(*)(double)  f,
double(*)(double, void *)  f_r,
void *  fdata,
double  a,
double  b,
double  c,
double *  err,
int  sqroot,
int  lev,
double  I0,
int  maxrecur,
int  paranoid 
)

◆ kgauss_sub() [2/2]

double mutils::kgauss_sub ( double(*)(double x)  f,
double(*)(double x, void *)  f_r,
void *  fdata,
double  a,
double  b,
double  c,
double *  acc,
int  root,
int  lev,
double  I0,
int  maxrecur,
int  paranoid 
)

◆ ksqrtgauss() [1/2]

double mutils::ksqrtgauss ( double(*)(double)  f,
double  a,
double  b,
double  c,
double  err 
)

◆ ksqrtgauss() [2/2]

double mutils::ksqrtgauss ( double(*)(double x)  f,
double  a,
double  b,
double  c,
double  err 
)

Definition at line 394 of file kgauss.cc.

References c_gl, func_gl, and kgauss_sub().

◆ ksqrtgauss_r() [1/2]

double mutils::ksqrtgauss_r ( double(*)(double, void *)  f_r,
void *  fdata,
double  a,
double  b,
double  c,
double  err 
)

◆ ksqrtgauss_r() [2/2]

double mutils::ksqrtgauss_r ( double(*)(double x, void *)  f_r,
void *  fdata,
double  a,
double  b,
double  c,
double  err 
)

Definition at line 424 of file kgauss.cc.

References kgauss_sub().

◆ lofn()

static double mutils::lofn ( double  x)
static

Definition at line 38 of file kgauss.cc.

References c_gl, and func_gl.

Referenced by kgauss_sub().

◆ lofn_r()

static double mutils::lofn_r ( double  x,
void *  vdata 
)
static

Definition at line 58 of file kgauss.cc.

References mutils::integ_data_t::c, mutils::integ_data_t::fdata, and mutils::integ_data_t::func.

Referenced by kgauss_sub().

◆ nullStr()

const std::string mutils::nullStr ( ,
 
)

◆ printException()

void mutils::printException ( std::exception &  ex)
inline

Prints exception message.

If ex is an mutils::Exception, calls mutils::Exception::print(); otherwise, prints ex.what() (to stderr).

Parameters
[in]exInput exception.

Definition at line 194 of file Exception.h.

References mutils::Exception::print().

Referenced by exitException().

◆ siPrefixes()

const std::string mutils::siPrefixes ( "YZEPTGMkhDdcmunpfazy"  )
Prefix Name Value Prefix Name Value
Y yotta 1024 y yocto 10-24
Z zetta 1021 z zepto 10-21
E exa 1018 a atto 10-18
P peta 1015 f femto 10-15
T tera 1012 p pico 10-12
G giga 109 n nano 10-9
M mega 106 u micro 10-6
k kilo 103 m milli 10-3
h hetco 102 c centi 10-2
D deka 101 d deci 10-1
See also
siScale(), siHasPrefix()

◆ sqr()

template<typename R >
R mutils::sqr ( x)

Computes square of a number.

Template Parameters
RFloating-point type.
Parameters
xArgument.
Returns
Square of argument.

Definition at line 26 of file kgauss.cc.

Referenced by kgauss_sub().

Variable Documentation

◆ c_gl

double mutils::c_gl
static

Definition at line 31 of file kgauss.cc.

Referenced by hifn(), ksqrtgauss(), and lofn().

◆ func_gl

double(* mutils::func_gl) (double x)
static

Definition at line 31 of file kgauss.cc.

Referenced by hifn(), ksqrtgauss(), and lofn().

◆ npos

std::string::size_type mutils::npos = std::string::npos

Definition at line 24 of file statics.cc.

Referenced by mutils::CommandLine::Option::keyword(), and mutils::CommandLine::usage().

◆ siScaleMap

const std::map<char, const char *> mutils::siScaleMap
Initial value:
{
{'Y', "1e24"}, {'Z', "1e21"}, {'E', "1e18"}, {'P', "1e15"},
{'T', "1e12"}, {'G', "1e9"}, {'M', "1e6"}, {'k', "1e3"},
{'h', "1e2"}, {'D', "1e1"}, {'d', "1e-1"}, {'c', "1e-2"},
{'m', "1e-3"}, {'u', "1e-6"}, {'n', "1e-9"}, {'p', "1e-12"},
{'f', "1e-15"}, {'a', "1e-18"}, {'z', "1e-21"}, {'y', "1e-24"}
}

Definition at line 45 of file statics.cc.