making dist
This commit is contained in:
parent
0cde98a554
commit
6ffe18f36a
32 changed files with 630 additions and 1017 deletions
|
@ -11,8 +11,6 @@ int t6_solve (
|
|||
double a, double b,
|
||||
const double eps, const int M, double *res
|
||||
) {
|
||||
double *maximum = d;
|
||||
|
||||
const int len = m + 1;
|
||||
|
||||
double *y_lst = d;
|
||||
|
@ -20,8 +18,20 @@ int t6_solve (
|
|||
double *t_lst = d + (len << 1);
|
||||
|
||||
int it;
|
||||
|
||||
if (is_eps(y_lst[0], eps)) {
|
||||
*res = a;
|
||||
return 1;
|
||||
} else if (is_eps(y_lst[m], eps)) {
|
||||
*res = b;
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (it = 1; it <= M; ++it)
|
||||
{
|
||||
double maximum = 0;
|
||||
int max_i = 0;
|
||||
|
||||
double x = construct_poly(0, len, y_lst, x_lst);
|
||||
double y = f(x);
|
||||
|
||||
|
@ -42,18 +52,17 @@ int t6_solve (
|
|||
if (is_equal(y, yi))
|
||||
return -1;
|
||||
|
||||
if ((fabs(yi) - fabs(*maximum)) > DBL_EPSILON)
|
||||
maximum = y_lst + i;
|
||||
if ((yi - maximum) > DBL_EPSILON) {
|
||||
maximum = yi;
|
||||
max_i = i;
|
||||
}
|
||||
}
|
||||
|
||||
*maximum = y;
|
||||
*(maximum + len) = x;
|
||||
*(maximum + (len << 1)) = x;
|
||||
|
||||
y_lst[max_i] = y;
|
||||
x_lst[max_i] = x;
|
||||
t_lst[max_i] = x;
|
||||
}
|
||||
|
||||
(void)a;
|
||||
(void)b;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue