20 if (a < 0) tmp = -1.0;
21 if (a == 0) tmp = 0.0;
22 if (a > 0) tmp = +1.0;
30 inline double min_par(
double a,
double b) {
45 int parabola(
int nmin,
int nmax,
double *a,
double *deltaa,
46 double *a6,
double *al,
int flag1,
double *diffa,
47 double *da,
double **para,
double *ar,
double *flat,
48 double *scratch1,
double *scratch2,
double *scratch3) {
50 double tmp1, tmp2, tmp3, onemfl;
53 for (i = nmin - 2; i <= nmax + 1; i++) {
54 diffa[i] = a[i + 1] - a[i];
59 for (i = nmin - 1; i <= nmax + 1; i++) {
60 da[i] = para[i][3] * diffa[i] + para[i][4] * diffa[i - 1];
61 tmp1 =
min_par(fabs(da[i]), 2.0 * fabs(diffa[i - 1]));
62 tmp2 =
min_par(2.0 * fabs(diffa[i]), tmp1);
69 for (i = nmin - 1; i <= nmax + 1; i++) {
70 if (diffa[i - 1] * diffa[i] < 0.0) da[i] = 0.0;
77 for (i = nmin - 1; i <= nmax; i++) {
78 ar[i] = a[i] + para[i][0] * diffa[i] + para[i][1] * da[i + 1] + para[i][2] * da[i];
83 for (i = nmin; i <= nmax; i++) {
84 onemfl = 1.0 - flat[i];
85 ar[i] = flat[i] * a[i] + onemfl * ar[i];
86 al[i] = flat[i] * a[i] + onemfl * al[i];
97 for (i = nmin; i <= nmax; i++) {
99 onemfl = 1.0 - flat[i];
100 ar[i] = flat[i] * a[i] + onemfl * ar[i];
101 al[i] = flat[i] * a[i] + onemfl * al[i];
103 deltaa[i] = ar[i] - al[i];
104 a6[i] = 6.0 * (a[i] - 0.5 * (al[i] + ar[i]));
105 scratch1[i] = (ar[i] - a[i])*(a[i] - al[i]);
106 scratch2[i] = deltaa[i] * deltaa[i];
107 scratch3[i] = deltaa[i] * a6[i];
109 if (scratch1[i] <= 0.0) {
113 if (scratch2[i] < +scratch3[i]) al[i] = 3.0 * a[i] - 2.0 * ar[i];
114 if (scratch2[i] < -scratch3[i]) ar[i] = 3.0 * a[i] - 2.0 * al[i];
117 deltaa[i] = ar[i] - al[i];
118 a6[i] = 6.0 * (a[i] - 0.5 * (al[i] + ar[i]));
122 for (i = nmin; i <= nmax; i++) {
123 if (scratch1[i] <= 0.0) {
127 if (scratch2[i] < +scratch3[i]) al[i] = 3.0 * a[i] - 2.0 * ar[i];
128 if (scratch2[i] < -scratch3[i]) ar[i] = 3.0 * a[i] - 2.0 * al[i];
133 for (i = nmin; i <= nmax; i++) {
134 deltaa[i] = ar[i] - al[i];
135 a6[i] = 6.0 * (a[i] - 0.5 * (al[i] + ar[i]));