Find an Error
This commit is contained in:
parent
093280d5cd
commit
dc3c871ae1
6 changed files with 43 additions and 37 deletions
|
@ -40,8 +40,7 @@ int t5_solve (
|
|||
return -1;
|
||||
|
||||
if (
|
||||
is_equal(y_a, y_b) ||
|
||||
is_equal(y_a, y_c) ||
|
||||
(is_equal(y_a, y_b) || is_equal(y_a, y_c)) ||
|
||||
is_equal(y_b, y_c)
|
||||
)
|
||||
return -3;
|
||||
|
@ -49,11 +48,26 @@ int t5_solve (
|
|||
for (it = 1; it < m+1; ++it)
|
||||
{
|
||||
double *temp_pnt = 0, *inner_max_pnt;
|
||||
const double angle = (c - a) / (y_c - y_a);
|
||||
const double x_new = a -
|
||||
double angle, x_new, y_new;
|
||||
|
||||
if (is_equal(y_a, y_b))
|
||||
return -3;
|
||||
else if (is_equal(y_a, y_c))
|
||||
return -3;
|
||||
else if (is_equal(y_b, y_c))
|
||||
return -3;
|
||||
|
||||
if (
|
||||
(is_equal(y_a, y_b) || is_equal(y_a, y_c)) ||
|
||||
is_equal(y_b, y_c)
|
||||
)
|
||||
return -3;
|
||||
|
||||
angle = (c - a) / (y_c - y_a);
|
||||
x_new = a -
|
||||
angle * y_a +
|
||||
((((b - c) / (y_b - y_c)) - angle) / (y_b - y_a)) * y_a * y_c;
|
||||
const double y_new = f(x_new);
|
||||
y_new = f(x_new);
|
||||
|
||||
if (is_eps(y_new, eps))
|
||||
{
|
||||
|
@ -62,15 +76,15 @@ int t5_solve (
|
|||
}
|
||||
|
||||
if (
|
||||
is_equal(x_new, a) ||
|
||||
is_equal(x_new, c) ||
|
||||
(is_equal(x_new, a) ||
|
||||
is_equal(x_new, c)) ||
|
||||
is_equal(x_new, b)
|
||||
)
|
||||
return -1;
|
||||
|
||||
if (
|
||||
is_equal(y_new, y_a) ||
|
||||
is_equal(y_new, y_c) ||
|
||||
(is_equal(y_new, y_a) ||
|
||||
is_equal(y_new, y_c)) ||
|
||||
is_equal(y_new, y_b)
|
||||
)
|
||||
return -3;
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define EPS 1e-16
|
||||
|
||||
static inline double * fpmax (double *pa, double *pb, double fa, double fb, double *max_f_p)
|
||||
{
|
||||
|
@ -34,7 +37,7 @@ static inline int is_equal (const double a, const double b)
|
|||
{
|
||||
double diff = a - b;
|
||||
double max_val = (a > b) ? a : b;
|
||||
return ((diff < 0) ? -diff : diff) < (DBL_EPSILON * max_val);
|
||||
return (fabs(diff) < (EPS * fabs(max_val)));
|
||||
}
|
||||
|
||||
static inline int is_null (const double a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue