9 #ifndef PYNE_KMMHYNANYFF5BFMEYIP7TUNLHA 10 #define PYNE_KMMHYNANYFF5BFMEYIP7TUNLHA 23 #include <sys/types.h> 30 #define isnan(x) std::isnan(x) 33 #define isnan(x) __isnand((double)x) 37 #define isnan(x) ((x) != (x)) 40 #ifndef JSON_IS_AMALGAMATION 41 #define JSON_IS_AMALGAMATION 56 static std::string digits =
"0123456789";
58 static std::string alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
60 static std::string words =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
65 std::string to_str(
int t);
66 std::string to_str(
unsigned int t);
67 std::string to_str(
double t);
68 std::string to_str(
bool t);
73 double to_dbl(std::string s);
79 extern double (*
endftod)(
char * s);
81 void use_fast_endftod();
94 int line_length = 79);
100 std::string
get_flag(
char line[],
int max_l);
130 std::vector<std::string> split_string(std::string lists, std::string delimiter =
" ");
134 std::string join_to_string(std::vector<T> vect, std::string delimiter =
" "){
135 std::stringstream out;
136 out << std::setiosflags(std::ios::fixed) << std::setprecision(6);
139 if (vect.size() == 0)
143 for(
int i = 1; i < vect.size(); i++)
144 out << delimiter << vect[i];
147 template std::string join_to_string(std::vector<int> vect,
148 std::string delimiter);
149 template std::string join_to_string(std::vector<double> vect,
150 std::string delimiter);
151 template std::string join_to_string(std::vector<std::string> vect, std::string delimiter);
154 double slope (
double x2,
double y2,
double x1,
double y1);
158 double solve_line (
double x,
double x2,
double y2,
double x1,
double y1);
160 double tanh(
double x);
161 double coth(
double x);
169 std::string get_full_filepath(
char* filename);
171 std::string get_full_filepath(std::string filename);
174 extern bool USE_WARNINGS;
196 FNF_message =
"File not found";
198 FNF_message +=
": " + fname;
202 virtual const char*
what()
const throw()
204 return FNF_message.c_str();
208 std::string FNF_message;
229 virtual const char*
what()
const throw()
231 std::string msgstr (
"ValueError: ");
232 if (!message.empty())
234 const char* msgstr_rtn = msgstr.c_str();
246 #endif // PYNE_KMMHYNANYFF5BFMEYIP7TUNLHA double to_dbl(std::string s)
Converts a valid string to a float using atof().
Definition: utils.cpp:80
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
Definition: data.cpp:835
std::string get_flag(char line[], int max_l)
Definition: utils.cpp:200
std::string natural_naming(std::string name)
Definition: utils.cpp:274
std::string last_char(std::string s)
Returns the last character in a string.
Definition: utils.cpp:249
double coth(double x)
The hyperbolic cotangent function.
Definition: utils.cpp:341
std::string PYNE_DATA
Path to the directory containing the PyNE data.
Definition: utils.cpp:14
bool ternary_ge(int a, int b, int c)
Returns true if a <= b <= c and flase otherwise.
Definition: utils.cpp:261
std::string to_lower(std::string s)
Returns an all lower case copy of the string.
Definition: utils.cpp:160
bool contains_substring(std::string s, std::string substr)
Returns true if substr is in s.
Definition: utils.cpp:267
bool toggle_warnings()
Toggles warnings on and off.
Definition: utils.cpp:396
double endftod_f(char *s)
Converts a string from ENDF format to a float.
Definition: utils.cpp:139
std::string NUC_DATA_PATH
Path to the nuc_data.h5 file.
Definition: utils.h:51
ValueError(std::string msg)
constructor with the filename fname.
Definition: utils.h:223
double endftod_cpp(char *s)
Definition: utils.cpp:84
~FileNotFound()
default destructor
Definition: utils.h:191
std::string slice_from_end(std::string s, int n=-1, int l=1)
Definition: utils.cpp:255
FileNotFound()
default constructor
Definition: utils.h:188
int to_int(std::string s)
Converts a string of digits to an int using atoi().
Definition: utils.cpp:76
std::string to_upper(std::string s)
switches endftod to fast cpp version
Definition: utils.cpp:153
ValueError()
default constructor
Definition: utils.h:217
~ValueError()
default destructor
Definition: utils.h:220
double slope(double x2, double y2, double x1, double y1)
Finds the slope of a line from the points (x1, y1) and (x2, y2).
Definition: utils.cpp:326
std::string comment_line_wrapping(std::string line, std::string comment_prefix="", int line_length=79)
Forms and returns the wrapped lines with a lenght up to line_lenght.
Definition: utils.cpp:167
FileNotFound(std::string fname)
constructor with the filename fname.
Definition: utils.h:194
std::string capitalize(std::string s)
Returns a capitalized copy of the string.
Definition: utils.cpp:187
virtual const char * what() const
Creates a helpful error message.
Definition: utils.h:202
void warning(std::string s)
Prints a warning message.
Definition: utils.cpp:401
A container representing enrichment cascades.
Definition: _atomic_data.h:16
std::string replace_all_substrings(std::string s, std::string substr, std::string repstr)
Replaces all instance of substr in s with repstr.
Definition: utils.cpp:237
bool file_exists(std::string strfilename)
Returns true if the file can be found.
Definition: utils.cpp:349
void pyne_start()
Initializes PyNE based on environment.
Definition: utils.cpp:18
double(* endftod)(char *s)
endftod function pointer. defaults to fortran
Definition: utils.cpp:147
std::string remove_characters(std::string s, std::string chars)
Removes all characters in the string chars from s.
Definition: utils.cpp:228
std::string VERSION
PyNE version number.
Definition: utils.cpp:16
virtual const char * what() const
Creates a helpful error message.
Definition: utils.h:229
double solve_line(double x, double x2, double y2, double x1, double y1)
Definition: utils.cpp:332
double tanh(double x)
The hyperbolic tangent function.
Definition: utils.cpp:337
Exception representing value errors of all kinds.
Definition: utils.h:212
std::string remove_substring(std::string s, std::string substr)
Creates a copy of s with all instances of substr taken out.
Definition: utils.cpp:217