Go to the documentation of this file.
39 #include <initializer_list>
42 #include <boost/multiprecision/cpp_dec_float.hpp>
45 #include <o2scl/err_hnd.h>
48 int o2scl_python_test(
int x);
51 #ifndef DOXYGEN_NO_O2NS
69 float o2abs(
const float x);
73 double o2abs(
const double x);
77 long double o2abs(
const long double x);
79 #if defined(O2SCL_LD_TYPES) || defined(DOXYGEN)
83 boost::multiprecision::cpp_dec_float_50
84 o2abs(
const boost::multiprecision::cpp_dec_float_50 x);
97 #if defined(O2SCL_LD_TYPES) || defined(DOXYGEN)
101 bool o2isfinite(
const boost::multiprecision::cpp_dec_float_50 x);
123 double fermi_function(
double E,
double mu,
double T,
double limit=40.0);
139 double bose_function(
double E,
double mu,
double T,
double limit=40.0);
153 bool err_on_fail=
true,
int nmax=80);
199 template<
class string_arr_t>
201 std::vector<std::string> &out_cols,
202 size_t max_size=80) {
208 size_t i,j,lmax,itemp;
209 std::string *in_spaces=
new std::string[nin];
214 if (lmax<in_cols[i].size()) lmax=in_cols[i].size();
219 itemp=in_cols[i].size();
220 in_spaces[i]=in_cols[i];
221 for(j=0;j<lmax+1-itemp;j++) {
228 col=max_size/(lmax+1);
230 if (nin/col*col==nin) row=nin/col;
234 out_cols.reserve(row);
236 out_cols.push_back(
"");
239 out_cols[i]+=in_spaces[i+j*row];
290 void RGBtoHSV(
double r,
double g,
double b,
291 double &h,
double &s,
double &v);
304 void HSVtoRGB(
double h,
double s,
double v,
305 double &r,
double &g,
double &b);
345 #ifndef DOXYGEN_INTERNAL
363 fact=((double)tot)/20.0;
368 double x, dtot=((double)tot), dn=((double)
n);
371 }
else if (
n==tot/2) {
373 }
else if (
n==tot-1) {
379 }
else if (
n<((
int)tot)/2) {
382 x=(std::tanh((dn-dtot/4.0)/
fact)-1.0)/2.0;
384 x=(std::tanh((dn-0.75*dtot)/
fact)+1.0)/2.0;
400 template<
class data_t>
402 const data_t
x3,
const data_t y1,
403 const data_t y2,
const data_t y3) {
406 O2SCL_ERR2(
"Two abscissae cannot be equal in function ",
436 a=((
x3-
x1)*(y2-y1)-(
x2-
x2)*(y3-y1))/den;
438 a=((
x3-
x2)*(y1-y2)-(
x1-
x2)*(y3-y2))/den;
457 template<
class data_t>
459 const data_t
x3,
const data_t y1,
460 const data_t y2,
const data_t y3,
461 const data_t &xmin,
const data_t &ymin,
462 const data_t &a,
const data_t &b,
463 const data_t &c,
const data_t &den) {
466 O2SCL_ERR2(
"Two abscissae cannot be equal in function ",
473 a=((
x3-
x1)*(y2-y1)-(
x2-
x2)*(y3-y1))/den;
475 a=((
x3-
x2)*(y1-y2)-(
x1-
x2)*(y3-y2))/den;
491 template<
class data_t>
493 const data_t
x3,
const data_t y1,
494 const data_t y2,
const data_t y3) {
497 O2SCL_ERR2(
"Two abscissae cannot be equal in function ",
504 a=((
x3-
x1)*(y2-y1)-(
x2-
x2)*(y3-y1))/den;
506 a=((
x3-
x2)*(y1-y2)-(
x1-
x2)*(y3-y2))/den;
521 template<
class data_t>
523 const data_t
x3,
const data_t y1,
524 const data_t y2,
const data_t y3,
525 data_t &x, data_t &y) {
528 O2SCL_ERR2(
"Two abscissae cannot be equal in function ",
535 a=((
x3-
x1)*(y2-y1)-(
x2-
x2)*(y3-y1))/den;
537 a=((
x3-
x2)*(y1-y2)-(
x1-
x2)*(y3-y2))/den;
555 template<
class data_t>
557 const data_t
x3,
const data_t y1,
558 const data_t y2,
const data_t y3,
559 data_t &a, data_t &b, data_t &c) {
562 O2SCL_ERR2(
"Two abscissae cannot be equal in function ",
569 a=((
x3-
x1)*(y2-y1)-(
x2-
x2)*(y3-y1))/den;
571 a=((
x3-
x2)*(y1-y2)-(
x1-
x2)*(y3-y2))/den;
580 #ifndef O2SCL_OLDER_COMPILER
589 std::map<std::string,size_t,std::greater<std::string> >
tmap;
600 for(
size_t i=0;i<list.size();i++) {
601 tmap.insert(std::make_pair(list[i],i));
602 tvec.push_back(list[i]);
609 for(std::initializer_list<std::string>::iterator it=list.begin();
610 it!=list.end();it++) {
611 tmap.insert(std::make_pair(*it,ix));
624 std::map<std::string,size_t,std::greater<std::string> >::iterator it;
626 if (it==
tmap.end()) {
627 std::string str=((std::string)
"Failed to find '")+s+
628 "' in vec_index::operator().";
641 std::map<std::string,size_t,std::greater<std::string> >::iterator it;
643 if (it==
tmap.end()) {
644 std::string str=((std::string)
"Failed to find '")+s+
645 "' in vec_index::operator[].";
653 tmap.insert(std::make_pair(s,
tvec.size()));
659 void append(std::initializer_list<std::string> list) {
660 size_t ix=
tvec.size();
661 for(std::initializer_list<std::string>::iterator it=list.begin();
662 it!=list.end();it++) {
663 tmap.insert(std::make_pair(*it,ix));
685 std::vector<std::string> &matches);
690 std::vector<std::string> &matches);
697 #ifndef DOXYGEN_NO_O2NS
std::string operator[](size_t i)
Return the string of index i.
void append(std::string s)
Add string s and assign it the next index.
void RGBtoHSV(double r, double g, double b, double &h, double &s, double &v)
Convert RGB to HSV color.
@ exc_efailed
generic failure
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
void quadratic_extremum_y_full(const data_t x1, const data_t x2, const data_t x3, const data_t y1, const data_t y2, const data_t y3, const data_t &xmin, const data_t &ymin, const data_t &a, const data_t &b, const data_t &c, const data_t &den)
Return values related to a quadratic defined by three pairs.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
Generate number sequence for testing.
int wordexp_wrapper(std::string word, std::vector< std::string > &matches)
Wrapper for the wordexp() function.
vec_index(std::initializer_list< std::string > list)
Create an assignment based on the strings in list.
vec_index(std::vector< std::string > &list)
Create an assignment based on the strings in list.
double fact
A constant factor for the argument to tanh(), equal to tot divided by 20.
size_t count_words(std::string str)
Count the number of words in the string str.
bool file_exists(std::string fname)
Return true if file named fname exists.
void append(std::initializer_list< std::string > list)
Add a list of strings.
void remove_whitespace(std::string &s)
Remove all whitespace from the string s.
double bose_function(double E, double mu, double T, double limit=40.0)
Calculate a Bose-Einstein distribution function safely.
static const double x2[5]
void screenify(size_t nin, const string_arr_t &in_cols, std::vector< std::string > &out_cols, size_t max_size=80)
Reformat the columns for output of width size.
data_t quadratic_extremum_x(const data_t x1, const data_t x2, const data_t x3, const data_t y1, const data_t y2, const data_t y3)
Return the x value of the extremum of a quadratic defined by three pairs.
A class to assign string labels to array indices.
double fermi_function(double E, double mu, double T, double limit=40.0)
Calculate a Fermi-Dirac distribution function safely.
static const double x1[5]
@ exc_einval
invalid argument supplied by user
int glob_wrapper(std::string pattern, std::vector< std::string > &matches)
Wrapper for the glob() function which finds files which match a pattern.
std::string binary_to_hex(std::string s)
Take a string of binary quads and compress them to hexadecimal digits.
data_t quadratic_extremum_y(const data_t x1, const data_t x2, const data_t x3, const data_t y1, const data_t y2, const data_t y3)
Return the y value of the extremum of a quadratic defined by three pairs.
void wordexp_single_file(std::string &fname)
Use wordexp() to obtain a single file.
double gen()
Return the next number in the sequence.
vec_index()
Create an empty assignment.
std::vector< std::string > tvec
The vector version for size_t lookup.
void quadratic_extremum_xy(const data_t x1, const data_t x2, const data_t x3, const data_t y1, const data_t y2, const data_t y3, data_t &x, data_t &y)
Return the (x,y) for the extremum of a quadratic defined by three pairs.
void HSVtoRGB(double h, double s, double v, double &r, double &g, double &b)
Convert RGB to HSV color.
void quadratic_extremum_coeffs(const data_t x1, const data_t x2, const data_t x3, const data_t y1, const data_t y2, const data_t y3, data_t &a, data_t &b, data_t &c)
Return the (x,y) for the extremum of a quadratic defined by three pairs.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
float o2abs(const float x)
Absolute value for single precision numbers.
int pipe_cmd_string(std::string cmd, std::string &result, bool err_on_fail=true, int nmax=80)
Store the first line from the output of the shell command cmd up to nmax characters in result.
std::map< std::string, size_t, std::greater< std::string > > tmap
The map version for string lookup.
size_t operator()(std::string s)
Return the index of string s.
std::string operator()(size_t i)
Return the string of index i.
bool o2isfinite(const double x)
Compatbility function for isfinite()
int n
Count number of numbers generated.
size_t operator[](std::string s)
Return the index of string s.
static const double x3[11]
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).