-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.hpp
More file actions
67 lines (55 loc) · 2.25 KB
/
util.hpp
File metadata and controls
67 lines (55 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* This file is a part of runjam <https://github.com/idthic/runjam>.
Copyright (C) 2014-2020, Koichi Murase <myoga.murase at gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA */
#ifndef runjam_util_hpp
#define runjam_util_hpp
#include <cstddef>
#include <map>
#include <string>
namespace idt {
// static const double hbarc_MeVfm = 197.32; // hydrojet/src/spectra/ElementReso.h
// static const double hbarc_MeVfm = 197.327053 ; // 197.327053 hydrojet/src/physicsbase/Const.h
constexpr double hbarc_MeVfm = 197.3269718; // 197.3269718(44) idt/rfh/i2/common/def.h
constexpr double hbarc_GeVfm = hbarc_MeVfm / 1000.0;
}
namespace idt {
namespace util {
bool ends_with(const char* s, std::size_t l, const char* suffix, std::size_t len);
bool ends_with(std::string const& s, std::string const& suffix);
bool ends_with(std::string const& s, const char* suffix);
bool ends_with(const char* s, const char* suffix);
}
}
#include <cstdarg>
namespace idt::util {
std::string vstrprintf(const char* fmt, std::va_list va);
std::string strprintf(const char* fmt, ...);
std::string strprintf(std::string const& fmt, ...);
}
#include <random>
namespace idt {
namespace util {
std::mt19937& random_engine();
void set_random_seed(int seed);
double urand(); // double [0,1)
double nrand(); // normal distribution N(μ=0, σ^2)
int irand(int n); // int [0,n)
std::size_t irand(std::size_t n); // int [0,n)
int irand_poisson(double lambda);
int irand_binomial(int trial, double probability);
std::size_t irand_binomial(std::size_t trial, double probability);
}
}
#endif