29 static Profile *cProfile = NULL;
31 static double f1(
double x) {
32 return (cProfile ? cProfile->
get(x) : 0.0);
35 static double f2(
double x) {
36 return (cProfile ?
pow(cProfile->
get(x), 2) : 0.0);
39 static double f3(
double x) {
40 return (cProfile ?
fabs(cProfile->
get(x)) : 0.0);
52 n(_n), x(_x, _x + _n), y(_y, _y + _n) {
61 f = fopen(fname,
"r");
63 std::cout <<
"Profile::Profile: Cannot load profile mapping " << fname <<
std::endl;
67 while(fscanf(f,
"%lf %lf", &a, &b) == 2) {
78 f = fopen(fname,
"r");
79 for(i = 0; i <
n; i++) {
80 int res = fscanf(f,
"%lf %lf", &x[i], &
y[i]);
90 while((i0 < n) && (
fabs(
y[i0]) < m)) ++i0;
91 if((i0 > 0) && (i0 < n)) {
92 for(i = i0; i <
n; i++) {
100 while((i0 >= 0) && (
fabs(
y[i0]) < m)) --i0;
101 if((i0 < (n - 1)) && (i0 >= 0)) n = i0;
118 for(i = 0; i <
n; i++) {
124 std::vector<std::pair<double,double>> xy(n);
125 for (
int i=0; i<
n; i++) {
126 xy[i] = std::make_pair(x[i],
y[i]);
129 std::sort(xy.begin(), xy.end(),
130 [](
const std::pair<double,double> &left,
const std::pair<double,double> &right)
131 {
return left.first < right.first;});
133 for (
int i=0; i<
n; i++) {
142 for(i = 0; i + j <
n; i++) {
146 while((i + j + k < n) && (x[i+j] == x[i+j+k])) {
164 if(x.empty()==
false) {
165 if(xa < x[0]) val = 0.0;
166 else if(xa > x[
n-1]) val = 0.0;
192 if(v > 0.0)
sf = f / v;
209 f = fopen(fname,
"w");
214 std::cout <<
"Profile::Profile: Failed to create profile output:" << fname <<
std::endl;
222 fprintf(f,
"SDDS1\n");
223 fprintf(f,
"¶meter name=n, type=long, fixed_value=%d &end\n",
n);
224 fprintf(f,
"¶meter name=sf, type=double, fixed_value=%20.12le &end\n",
sf);
225 fprintf(f,
"&column name=x, type=double &end\n");
226 fprintf(f,
"&column name=y, type=double &end\n");
227 fprintf(f,
"&data mode=ascii &end\n");
229 fprintf(f,
"! next page\n");
230 fprintf(f,
" %d\n",
n);
231 for(i = 0; i <
n; i++) {
232 fprintf(f,
"%20.12le \t %20.12le\n", x[i] + dx,
sf *
y[i]);
234 fprintf(f,
"! next page\n");
235 fprintf(f,
" %d\n", 10 * n);
237 dxx = (x[n-1] - x[0]) / (10 * n - 1);
238 for(i = 0; i < 10 *
n; i++) {
240 fprintf(f,
"%20.12le \t %20.12le\n", xx + dx,
get(xx));
257 return ((x.empty()==
false) ? x[
n-1] : 0.0);
261 return ((x.empty()==
false) ? x[0] : 0.0);
269 return ((x.empty() || (x[
n-1] == x[0]) || (ym == 0.0)) ? 0.0 :
278 return ((x.empty() || (x[
n-1] == x[0]) || (ym == 0.0)) ? 0.0 :
287 return ((x.empty() || (x[
n-1] == x[0]) || (ym == 0.0)) ? 0.0 :
double qromb(double(*func)(double), double a, double b, double eps)
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
double get(double, Interpol_type=itype_spline)
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
void dump(FILE *=stdout, double=0.0)
void spline(double x[], double y[], int n, double y2[])
void lsplint(double xa[], double ya[], double y2a[], int n, double x, double *y)
Inform & endl(Inform &inf)