8double chispre(std::vector<double> &f,
int s_allow_zero_f) {
9 mfunnamep(
"double chispre(vector<double>& f, int s_allow_zero_f)");
10 const size_t q = f.size();
13 for (
size_t i = 0; i < q; ++i) {
14 if (s_allow_zero_f == 0) {
18 mcout <<
"Warning: f[i] < 0.0 in chispre\n";
27 const double scale = 1. / r;
28 for (
size_t i = 0; i < q; ++i) f[i] *= scale;
32double chisran(
double flat_random_number,
const std::vector<double> &f) {
33 mfunnamep(
"double chisran(double flat_random_number, vector<double>& f)");
34 const long q = f.size();
37 if (flat_random_number == 0.0) {
38 for (
long n = 0; n < q; ++n) {
39 if (f[n] > 0.0)
return double(n);
42 if (flat_random_number == 1.0) {
43 for (
long n = q - 1; n >= 0; n--) {
44 if (f[n] < 1.0)
return double(n + 1);
47 if (flat_random_number <= f[0]) {
48 return flat_random_number / f[0];
55 if (flat_random_number < f[nc]) {
61 const double xl = double(nl + 1);
62 const double xr = double(nr + 1);
63 const double yl = f[nl];
64 const double yr = f[nr];
65 const double a = (xr - xl) / (yr - yl);
71 return a * (flat_random_number - yl) + b;
75 mcerr <<
"should never happen\n";
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
#define check_econd11(a, signb, stream)
#define check_econd11a(a, signb, add, stream)
#define mfunnamep(string)
double chisran(double flat_random_number, const std::vector< double > &f)
double chispre(std::vector< double > &f, int s_allow_zero_f)
#define Iprint2n(file, name1, name2)