misc.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2017, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_MISC_H
24 #define O2SCL_MISC_H
25 /** \file misc.h
26  \brief Miscellaneous functions
27 */
28 
29 #include <cstdlib>
30 #include <iostream>
31 #include <string>
32 // For stringstream for count_words()
33 #include <sstream>
34 #include <vector>
35 // For std::isinf and std::isnan in C++11
36 #include <cmath>
37 // For the vec_index class below
38 #include <map>
39 #include <initializer_list>
40 
41 #include <o2scl/err_hnd.h>
42 
43 extern "C" {
44  int o2scl_python_test(int x);
45 }
46 
47 #ifndef DOXYGEN_NO_O2NS
48 namespace o2scl {
49 #endif
50 
51  /// \name Functions from misc.h
52  //@{
53  /** \brief Calculate a Fermi-Dirac distribution function safely
54 
55  \f$ \left[1+\exp\left(E/T-\mu/T\right)\right]^{-1} \f$
56 
57  This calculates a Fermi-Dirac distribution function guaranteeing
58  that numbers larger than \f$ \exp(\mathrm{limit}) \f$ and
59  smaller than \f$ \exp(-\mathrm{limit}) \f$ will be avoided. The
60  default value of <tt>limit=40</tt> ensures accuracy to within 1
61  part in \f$ 10^{17} \f$ compared to the maximum of the
62  distribution (which is unity).
63 
64  Note that this function may return Inf or NAN if \c limit is too
65  large, depending on the machine precision.
66  */
67  double fermi_function(double E, double mu, double T, double limit=40.0);
68 
69  /** \brief Store the first line from the output of the shell
70  command \c cmd up to \c nmax characters in \c result
71 
72  \note This function uses popen() and may not work properly on
73  some systems. If HAVE_POPEN was not defined during O2scl's
74  compilation, then this function will throw an exception (or if
75  \c err_on_fail is false, it will return a nonzero value).
76 
77  \note The result string may contain a carriage return at
78  the end.
79  */
80  int pipe_cmd_string(std::string cmd, std::string &result,
81  bool err_on_fail=true, int nmax=80);
82 
83  /** \brief Return the first line from the output of the shell
84  command \c cmd up to \c nmax characters
85 
86  This function always throws exceptions if it fails.
87 
88  \note The result string may contain a carriage return at
89  the end.
90  */
91  std::string pipe_cmd_string(std::string cmd, int nmax=80);
92 
93  /** \brief Reformat the columns for output of width \c size
94 
95  Given a string array \c in_cols of size \c nin, screenify()
96  reformats the array into columns creating a new string array \c
97  out_cols.
98 
99  For example, for an array of 10 strings
100  \verbatim
101  test1
102  test_of_string2
103  test_of_string3
104  test_of_string4
105  test5
106  test_of_string6
107  test_of_string7
108  test_of_string8
109  test_of_string9
110  test_of_string10
111  \endverbatim
112  screenify() will create an array of 3 new strings:
113  \verbatim
114  test1 test_of_string4 test_of_string7 test_of_string10
115  test_of_string2 test5 test_of_string8
116  test_of_string3 test_of_string6 test_of_string9
117  \endverbatim
118 
119  If the value of \c max_size is less than the length of the
120  longest input string (plus one for a space character), then the
121  output strings may have a larger length than \c max_size.
122  */
123  template<class string_arr_t>
124  void screenify(size_t nin, const string_arr_t &in_cols,
125  std::vector<std::string> &out_cols,
126  size_t max_size=80) {
127 
128  if (nin==0) {
129  O2SCL_ERR("No strings specified in screenify().",exc_efailed);
130  }
131 
132  size_t i,j,lmax,itemp;
133  std::string *in_spaces=new std::string[nin];
134 
135  // Determine size of largest string
136  lmax=0;
137  for(i=0;i<nin;i++) {
138  if (lmax<in_cols[i].size()) lmax=in_cols[i].size();
139  }
140 
141  // Pad with spaces
142  for(i=0;i<nin;i++) {
143  itemp=in_cols[i].size();
144  in_spaces[i]=in_cols[i];
145  for(j=0;j<lmax+1-itemp;j++) {
146  in_spaces[i]+=' ';
147  }
148  }
149 
150  // Determine number of rows and columns
151  size_t row, col;
152  col=max_size/(lmax+1);
153  if (col==0) col=1;
154  if (nin/col*col==nin) row=nin/col;
155  else row=nin/col+1;
156 
157  // Create outc
158  out_cols.reserve(row);
159  for(i=0;i<row;i++) {
160  out_cols.push_back("");
161  for(j=0;j<col;j++) {
162  if (i+j*row<nin) {
163  out_cols[i]+=in_spaces[i+j*row];
164  }
165  }
166  }
167 
168  delete[] in_spaces;
169 
170  return;
171  }
172 
173  /** \brief Count the number of words in the string \c str
174 
175  Words are defined as groups of characters separated by
176  whitespace, where whitespace is any combination of adjacent
177  spaces, tabs, carriage returns, etc. On most systems, whitespace
178  is usually defined as any character corresponding to the
179  integers 9 (horizontal tab), 10 (line feed), 11 (vertical tab),
180  12 (form feed), 13 (carriage return), and 32 (space bar). The
181  test program \c misc_ts enumerates the characters between 0 and
182  255 (inclusive) that count as whitespace for this purpose.
183 
184  \future Make consistent with split_string().
185  */
186  size_t count_words(std::string str);
187 
188  /** \brief Remove all whitespace from the string \c s
189 
190  This function removes all characters in \c s which correspond to
191  the integer values 9, 10, 11, 12, 13, or 32.
192  */
193  void remove_whitespace(std::string &s);
194 
195  /** \brief Take a string of binary quads and compress them to
196  hexadecimal digits
197 
198  This function proceeds from left to right, ignoring parts of the
199  string that do not consist of squences of four '1's or '0's.
200  */
201  std::string binary_to_hex(std::string s);
202 
203  /** \brief Convert RGB to HSV color
204 
205  Taken from Nathan Schaller's webpage at
206  http://www.cs.rit.edu/~ncs/color/t_convert.html
207 
208  The inputs should be in the ranges \f$ h \in [0,360] \f$, \f$ s
209  \in [0,1] \f$, and \f$ v \in [0,1] \f$. The output values \c r,
210  \c g, and \c b are \f$ \in [0,1] \f$.
211 
212  If s == 0, then h = -1 (undefined)
213  */
214  void RGBtoHSV(double r, double g, double b,
215  double &h, double &s, double &v);
216 
217  /** \brief Convert RGB to HSV color
218 
219  Taken from Nathan Schaller's webpage at
220  http://www.cs.rit.edu/~ncs/color/t_convert.html
221 
222  The inputs should be in the ranges \f$ h \in [0,360] \f$, \f$ s
223  \in [0,1] \f$, and \f$ v \in [0,1] \f$. The output values \c r,
224  \c g, and \c b are \f$ \in [0,1] \f$.
225 
226  If s == 0, then h = -1 (undefined)
227  */
228  void HSVtoRGB(double h, double s, double v,
229  double &r, double &g, double &b);
230  //@}
231 
232  /** \brief Generate number sequence for testing
233 
234  A class which generates \c tot numbers from -1 to 1, making sure
235  to include -1, 1, 0, and numbers near -1, 0 and 1 (so long as \c
236  tot is sufficiently large). If gen() is called more than \c tot
237  times, it just recycles through the list again.
238 
239  This class is used to generate combinations of coefficients for
240  testing the polynomial solvers.
241 
242  For example, the first 15 numbers generated by
243  an object of type gen_test_number<10> are:
244  \verbatim
245  0 -1.000000e+00
246  1 -9.975274e-01
247  2 -8.807971e-01
248  3 -1.192029e-01
249  4 -2.472623e-03
250  5 +0.000000e+00
251  6 +2.472623e-03
252  7 +1.192029e-01
253  8 +8.807971e-01
254  9 +1.000000e+00
255  10 -1.000000e+00
256  11 -9.975274e-01
257  12 -8.807971e-01
258  13 -1.192029e-01
259  14 -2.472623e-03
260  \endverbatim
261 
262  This function is used in <tt>src/other/poly_ts.cpp</tt> which
263  tests the polynomial solvers.
264 
265  \future Document what happens if \c tot is pathologically small.
266  */
267  template<size_t tot> class gen_test_number {
268 
269 #ifndef DOXYGEN_INTERNAL
270 
271  protected:
272 
273  /// Count number of numbers generated
274  int n;
275 
276  /** \brief A constant factor for the argument to
277  <tt>tanh()</tt>, equal to \c tot divided by 20.
278  */
279  double fact;
280 
281 #endif
282 
283  public:
284 
285  gen_test_number() {
286  n=0;
287  fact=((double)tot)/20.0;
288  }
289 
290  /// Return the next number in the sequence
291  double gen() {
292  double x, dtot=((double)tot), dn=((double)n);
293  if (n==0) {
294  x=-1.0;
295  } else if (n==tot/2) {
296  x=0.0;
297  } else if (n==tot-1) {
298  x=1.0;
299  } else if (n==tot) {
300  // Start the sequence over
301  x=-1.0;
302  n=0;
303  } else if (n<((int)tot)/2) {
304  // Since we're in the o2scl namespace, we explicitly
305  // specify std::tanh() here
306  x=(std::tanh((dn-dtot/4.0)/fact)-1.0)/2.0;
307  } else {
308  x=(std::tanh((dn-0.75*dtot)/fact)+1.0)/2.0;
309  }
310  n++;
311  return x;
312  }
313  };
314 
315  /** \brief Return the x value of the extremum of a quadratic defined by
316  three \f$ (x,y) \f$ pairs
317 
318  This function should work for any floating-point data type,
319  but will suffer from problems due to lack of precision in
320  some cases.
321  */
322  template<class data_t>
323  data_t quadratic_extremum_x(const data_t x1, const data_t x2,
324  const data_t x3, const data_t y1,
325  const data_t y2, const data_t y3) {
326 
327  if (x1==x2 || x2==x3 || x1==x3) {
328  O2SCL_ERR2("Two abscissae cannot be equal in function ",
329  "quadratic_extremum_x().",exc_einval);
330  }
331 
332  /*
333  Start with:
334  y1=a x1^2 + b x1 + c
335  y2=a x2^2 + b x2 + c
336  y3=a x3^2 + b x3 + c
337 
338  Eliminate 'c':
339  (y1-y2)=a(x1^2-x2^2)+b(x1-x2)
340  (y3-y2)=a(x3^2-x2^2)+b(x3-x2)
341 
342  Eliminate 'b':
343  (x3-x2)*(y1-y2)=a*(x1^2-x2^2)*(x3-x2)+b*(x1-x2)*(x3-x2)
344  (x1-x2)*(y3-y2)=a*(x3^2-x2^2)*(x1-x2)+b*(x3-x2)*(x1-x2)
345 
346  Alternatively, eliminate 'c' with:
347  (y2-y1)=a(x2^2-x1^2)+b(x2-x1)
348  (y3-y1)=a(x3^2-x1^2)+b(x3-x1)
349 
350  Eliminate 'b':
351  (x3-x1)*(y2-y1)=a(x2^2-x1^2)*(x3-x1)+b(x2-x1)*(x3-x1)
352  (x2-x1)*(y3-y1)=a(x3^2-x1^2)*(x2-x1)+b(x3-x1)*(x2-x1)
353  */
354 
355  data_t a,b,c,den=(x1*x1-x2*x2)*(x3-x2)-(x3*x3-x2*x2)*(x1-x2);
356  if (den==0.0) {
357  den=(x2*x2-x1*x1)*(x3-x1)-(x3*x3-x1*x1)*(x2-x1);
358  a=((x3-x1)*(y2-y1)-(x2-x2)*(y3-y1))/den;
359  } else {
360  a=((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2))/den;
361  }
362  b=(y1-y2-a*(x1*x1-x2*x2))/(x1-x2);
363  c=y2-a*x2*x2-b*x2;
364 
365  return -b/2.0/a;
366  }
367 
368  /** \brief Return values related to a quadratic defined by
369  three \f$ (x,y) \f$ pairs
370 
371  This function provides the three coefficients of the
372  quadratic, \c a, \c b, and \c c, and the denominator
373  \c den.
374 
375  This function should work for any floating-point data type,
376  but will suffer from problems due to lack of precision in
377  some cases.
378  */
379  template<class data_t>
380  void quadratic_extremum_y_full(const data_t x1, const data_t x2,
381  const data_t x3, const data_t y1,
382  const data_t y2, const data_t y3,
383  const data_t &xmin, const data_t &ymin,
384  const data_t &a, const data_t &b,
385  const data_t &c, const data_t &den) {
386 
387  if (x1==x2 || x2==x3 || x1==x3) {
388  O2SCL_ERR2("Two abscissae cannot be equal in function ",
389  "quadratic_extremum_y().",exc_einval);
390  }
391 
392  den=(x1*x1-x2*x2)*(x3-x2)-(x3*x3-x2*x2)*(x1-x2);
393  if (den==0.0) {
394  den=(x2*x2-x1*x1)*(x3-x1)-(x3*x3-x1*x1)*(x2-x1);
395  a=((x3-x1)*(y2-y1)-(x2-x2)*(y3-y1))/den;
396  } else {
397  a=((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2))/den;
398  }
399  b=(y1-y2-a*(x1*x1-x2*x2))/(x1-x2);
400  c=y2-a*x2*x2-b*x2;
401  xmin=-b/2.0/a;
402  ymin=c-b*b/4.0/a;
403  return;
404  }
405 
406  /** \brief Return the y value of the extremum of a quadratic defined by
407  three \f$ (x,y) \f$ pairs
408 
409  This function should work for any floating-point data type,
410  but will suffer from problems due to lack of precision in
411  some cases.
412  */
413  template<class data_t>
414  data_t quadratic_extremum_y(const data_t x1, const data_t x2,
415  const data_t x3, const data_t y1,
416  const data_t y2, const data_t y3) {
417 
418  if (x1==x2 || x2==x3 || x1==x3) {
419  O2SCL_ERR2("Two abscissae cannot be equal in function ",
420  "quadratic_extremum_y().",exc_einval);
421  }
422 
423  data_t a,b,c,den=(x1*x1-x2*x2)*(x3-x2)-(x3*x3-x2*x2)*(x1-x2);
424  if (den==0.0) {
425  den=(x2*x2-x1*x1)*(x3-x1)-(x3*x3-x1*x1)*(x2-x1);
426  a=((x3-x1)*(y2-y1)-(x2-x2)*(y3-y1))/den;
427  } else {
428  a=((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2))/den;
429  }
430  b=(y1-y2-a*(x1*x1-x2*x2))/(x1-x2);
431  c=y2-a*x2*x2-b*x2;
432 
433  return c-b*b/4/a;
434  }
435 
436  /** \brief Return the (x,y) for the extremum of a quadratic defined by
437  three \f$ (x,y) \f$ pairs
438 
439  This function should work for any floating-point data type,
440  but will suffer from problems due to lack of precision in
441  some cases.
442  */
443  template<class data_t>
444  void quadratic_extremum_xy(const data_t x1, const data_t x2,
445  const data_t x3, const data_t y1,
446  const data_t y2, const data_t y3,
447  data_t &x, data_t &y) {
448 
449  if (x1==x2 || x2==x3 || x1==x3) {
450  O2SCL_ERR2("Two abscissae cannot be equal in function ",
451  "quadratic_extremum_xy().",exc_einval);
452  }
453 
454  data_t a,b,c,den=(x1*x1-x2*x2)*(x3-x2)-(x3*x3-x2*x2)*(x1-x2);
455  if (den==0.0) {
456  den=(x2*x2-x1*x1)*(x3-x1)-(x3*x3-x1*x1)*(x2-x1);
457  a=((x3-x1)*(y2-y1)-(x2-x2)*(y3-y1))/den;
458  } else {
459  a=((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2))/den;
460  }
461  b=(y1-y2-a*(x1*x1-x2*x2))/(x1-x2);
462  c=y2-a*x2*x2-b*x2;
463 
464  x=-b/2/a;
465  y=c-b*b/4/a;
466 
467  return;
468  }
469 
470  /** \brief Return the (x,y) for the extremum of a quadratic defined by
471  three \f$ (x,y) \f$ pairs
472 
473  This function should work for any floating-point data type,
474  but will suffer from problems due to lack of precision in
475  some cases.
476  */
477  template<class data_t>
478  void quadratic_extremum_coeffs(const data_t x1, const data_t x2,
479  const data_t x3, const data_t y1,
480  const data_t y2, const data_t y3,
481  data_t &a, data_t &b, data_t &c) {
482 
483  if (x1==x2 || x2==x3 || x1==x3) {
484  O2SCL_ERR2("Two abscissae cannot be equal in function ",
485  "quadratic_extremum_coeffs().",exc_einval);
486  }
487 
488  data_t den=(x1*x1-x2*x2)*(x3-x2)-(x3*x3-x2*x2)*(x1-x2);
489  if (den==0.0) {
490  den=(x2*x2-x1*x1)*(x3-x1)-(x3*x3-x1*x1)*(x2-x1);
491  a=((x3-x1)*(y2-y1)-(x2-x2)*(y3-y1))/den;
492  } else {
493  a=((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2))/den;
494  }
495  b=(y1-y2-a*(x1*x1-x2*x2))/(x1-x2);
496  c=y2-a*x2*x2-b*x2;
497 
498  return;
499  }
500 
501 #ifndef O2SCL_OLDER_COMPILER
502 
503  /** \brief A class to assign string labels to array indices
504  */
505  class vec_index {
506 
507  protected:
508 
509  /// The map version for string lookup
510  std::map<std::string,size_t,std::greater<std::string> > tmap;
511  /// The vector version for size_t lookup
512  std::vector<std::string> tvec;
513 
514  public:
515 
516  /// Create an empty assignment
518 
519  /// Create an assignment based on the strings in \c list
520  vec_index(std::vector<std::string> &list) {
521  for(size_t i=0;i<list.size();i++) {
522  tmap.insert(std::make_pair(list[i],i));
523  tvec.push_back(list[i]);
524  }
525  }
526 
527  /// Create an assignment based on the strings in \c list
528  vec_index(std::initializer_list<std::string> list) {
529  size_t ix=0;
530  for(std::initializer_list<std::string>::iterator it=list.begin();
531  it!=list.end();it++) {
532  tmap.insert(std::make_pair(*it,ix));
533  tvec.push_back(*it);
534  ix++;
535  }
536  }
537 
538  /// Return the string of index \c i
539  std::string operator()(size_t i) {
540  return tvec[i];
541  }
542 
543  /// Return the index of string \c s
544  size_t operator()(std::string s) {
545  std::map<std::string,size_t,std::greater<std::string> >::iterator it;
546  it=tmap.find(s);
547  if (it==tmap.end()) {
548  std::string str=((std::string)"Failed to find '")+s+
549  "' in vec_index::operator().";
550  O2SCL_ERR(str.c_str(),o2scl::exc_efailed);
551  }
552  return it->second;
553  }
554 
555  /// Return the string of index \c i
556  std::string operator[](size_t i) {
557  return tvec[i];
558  }
559 
560  /// Return the index of string \c s
561  size_t operator[](std::string s) {
562  std::map<std::string,size_t,std::greater<std::string> >::iterator it;
563  it=tmap.find(s);
564  if (it==tmap.end()) {
565  std::string str=((std::string)"Failed to find '")+s+
566  "' in vec_index::operator[].";
567  O2SCL_ERR(str.c_str(),o2scl::exc_efailed);
568  }
569  return it->second;
570  }
571 
572  /// Add string \c s and assign it the next index
573  void append(std::string s) {
574  tmap.insert(std::make_pair(s,tvec.size()));
575  tvec.push_back(s);
576  return;
577  }
578 
579  /// Add a list of strings
580  void append(std::initializer_list<std::string> list) {
581  size_t ix=tvec.size();
582  for(std::initializer_list<std::string>::iterator it=list.begin();
583  it!=list.end();it++) {
584  tmap.insert(std::make_pair(*it,ix));
585  tvec.push_back(*it);
586  ix++;
587  }
588  }
589  };
590 
591 #endif
592 
593 #ifndef DOXYGEN_NO_O2NS
594 }
595 #endif
596 
597 #endif
598 
std::string binary_to_hex(std::string s)
Take a string of binary quads and compress them to hexadecimal digits.
double fact
A constant factor for the argument to tanh(), equal to tot divided by 20.
Definition: misc.h:279
The main O<span style=&#39;position: relative; top: 0.3em; font-size: 0.8em&#39;>2</span>scl O$_2$scl names...
Definition: anneal.h:42
void remove_whitespace(std::string &s)
Remove all whitespace from the string s.
void HSVtoRGB(double h, double s, double v, double &r, double &g, double &b)
Convert RGB to HSV color.
invalid argument supplied by user
Definition: err_hnd.h:59
size_t operator()(std::string s)
Return the index of string s.
Definition: misc.h:544
double fermi_function(double E, double mu, double T, double limit=40.0)
Calculate a Fermi-Dirac distribution function safely.
A class to assign string labels to array indices.
Definition: misc.h:505
std::map< std::string, size_t, std::greater< std::string > > tmap
The map version for string lookup.
Definition: misc.h:510
generic failure
Definition: err_hnd.h:61
vec_index(std::initializer_list< std::string > list)
Create an assignment based on the strings in list.
Definition: misc.h:528
std::string operator[](size_t i)
Return the string of index i.
Definition: misc.h:556
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.
Definition: misc.h:323
vec_index(std::vector< std::string > &list)
Create an assignment based on the strings in list.
Definition: misc.h:520
static const double x3[11]
Definition: inte_qng_gsl.h:94
Generate number sequence for testing.
Definition: misc.h:267
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
Definition: err_hnd.h:281
double gen()
Return the next number in the sequence.
Definition: misc.h:291
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.
Definition: misc.h:414
void append(std::string s)
Add string s and assign it the next index.
Definition: misc.h:573
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.
Definition: misc.h:124
void append(std::initializer_list< std::string > list)
Add a list of strings.
Definition: misc.h:580
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
Definition: err_hnd.h:273
std::string operator()(size_t i)
Return the string of index i.
Definition: misc.h:539
void RGBtoHSV(double r, double g, double b, double &h, double &s, double &v)
Convert RGB to HSV color.
size_t operator[](std::string s)
Return the index of string s.
Definition: misc.h:561
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.
Definition: misc.h:478
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.
Definition: misc.h:444
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.
Definition: misc.h:380
std::vector< std::string > tvec
The vector version for size_t lookup.
Definition: misc.h:512
int n
Count number of numbers generated.
Definition: misc.h:274
size_t count_words(std::string str)
Count the number of words in the string str.
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...
static const double x2[5]
Definition: inte_qng_gsl.h:66
static const double x1[5]
Definition: inte_qng_gsl.h:48
vec_index()
Create an empty assignment.
Definition: misc.h:517

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).