20 const std::vector<double>& fy,
double fxmin,
double fxmax)
21 : xmin(fxmin), xmax(fxmax), x(fx), y(fy) {
26 const long q = x.size();
27 for (
long n = 0; n < q - 1; n++) {
30 for (
long n = 0; n < q; n++) {
35 for (
long n = 0; n < q - 1; n++) {
36 a[n] = (y[n + 1] - y[n]) / (x[n + 1] - x[n]);
39 double y0 = y[0] - a[0] * (x[0] - xmin);
41 x[0] = x[0] - y[0] / a[0];
50 if (xmax > x[q - 1]) {
51 double yq = y[q - 1] + a[q - 2] * (xmax - x[q - 1]);
53 x[q - 1] = x[q - 1] - y[q - 1] / a[0];
66 for (
long n = 1; n < q; n++) {
67 iy[n] = iy[n - 1] + 0.5 * (x[n] - x[n - 1]) * (y[n - 1] + y[n]);
71 }
else if (xmin > x[n - 1]) {
73 (xmin - x[n - 1]) * (y[n - 1] + 0.5 * a[n - 1] * (xmin - x[n - 1]));
79 }
else if (xmax > x[n - 1]) {
81 (xmax - x[n - 1]) * (y[n - 1] + 0.5 * a[n - 1] * (xmax - x[n - 1]));
85 integ_active = integ_finish - integ_start;
92 mfunnamep(
"double PointsRan::ran(double flat_ran) const");
93 flat_ran = integ_start + integ_active * flat_ran;
99 n3 = n1 + (n2 - n1) / 2;
100 if (flat_ran < iy[n3]) {
106 double dran = flat_ran - iy[n1];
110 dx = (-y[n1] +
sqrt(y[n1] * y[n1] + 2.0 * a[n1] * dran)) / a[n1];
112 dx = (x[n2] - x[n1]) / (iy[n2] - iy[n1]) * dran;
116 double r = x[n1] + dx;
121 Ifile <<
"PointsRan:\n";
123 Ifile <<
"xmin=" << xmin <<
" xmax=" << xmax <<
'\n';
124 Ifile <<
"n_start=" << n_start <<
" n_finish=" << n_finish <<
'\n';
125 Ifile <<
"integ_start=" << integ_start <<
" integ_finish=" << integ_finish
127 Ifile <<
"integ_total=" << integ_total <<
" integ_active=" << integ_active
130 const long q = x.size();
132 for (
long n = 0; n < q; n++) {
133 file << std::setw(3) << n <<
' ' << std::setw(12) << x[n] <<
' '
134 << std::setw(12) << y[n] <<
' ' << std::setw(12) << iy[n];
135 if (n < q - 1) file <<
' ' << std::setw(12) << a[n];
#define check_econd11(a, signb, stream)
#define mfunnamep(string)
#define check_econd12(a, sign, b, stream)
void print(std::ostream &file) const
double ran(double flat_ran) const
DoubleAc sqrt(const DoubleAc &f)
#define Iprintn(file, name)