CLASS  5.1
Fuel Cycle Simulator
CLASSMethod.hxx
Go to the documentation of this file.
1 #ifndef _CLASSMETHOD_
2 #define _CLASSMETHOD_
3 
4 #include <cmath>
5 #include <iostream>
6 #include <iomanip>
7 #include <stdlib.h>
8 #include <algorithm>
9 
10 struct my_tolower
11 {
12  char operator()(char c) const
13  {
14  return std::tolower(static_cast<unsigned char>(c));
15  }
16 };
17 
18 //To Lower Case, convert any string in lower case
19 static std::string tlc(string data)
20 {
21  transform(data.begin(), data.end(), data.begin(), my_tolower());
22  return data;
23 };
24 
25 
26 
27 static float random(float a, float b) //peak random numebr between a and b
28 {
29  float range = pow(2., 31);
30  srand(time(NULL)); //initialize the srand
31  return (float)a + (float)(b-a)*rand()/range;
32 };
33 
34 static std::string dtoa(double num)
35 {
36  std::ostringstream os(std::ostringstream::out);
37  os << setprecision(3) << num;
38  return os.str();
39 };
40 
41 
42 #endif
char operator()(char c) const
Definition: CLASSMethod.hxx:12
Definition: CLASSMethod.hxx:10