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

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