Task 5 is already done
This commit is contained in:
parent
7dc4921cef
commit
47a464aa9e
5 changed files with 120 additions and 55 deletions
|
|
@ -1,7 +1,53 @@
|
|||
#ifndef SOLVE_H
|
||||
#define SOLVE_H
|
||||
|
||||
int t1_solve (
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
static inline double * fpmax (double *pa, double *pb, double fa, double fb, double *max_f_p)
|
||||
{
|
||||
if ((fa - fb) > DBL_EPSILON)
|
||||
{
|
||||
*max_f_p = fa;
|
||||
return pa;
|
||||
} else
|
||||
{
|
||||
*max_f_p = fb;
|
||||
return pb;
|
||||
}
|
||||
}
|
||||
|
||||
static inline double * fp_abs_max (double *pa, double *pb, double *fa, double *fb, double **max_f_p)
|
||||
{
|
||||
if ((fabs(*fa) - fabs(*fb)) > DBL_EPSILON)
|
||||
{
|
||||
*max_f_p = fa;
|
||||
return pa;
|
||||
} else
|
||||
{
|
||||
*max_f_p = fb;
|
||||
return pb;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static inline int is_null (const double a)
|
||||
{
|
||||
return ((a < 0) ? -a : a) < DBL_EPSILON;
|
||||
}
|
||||
|
||||
static inline int is_eps (const double a, const double eps)
|
||||
{
|
||||
return (((a < 0) ? -a : a) - eps) < DBL_EPSILON;
|
||||
}
|
||||
|
||||
int t5_solve (
|
||||
double (*f) (double),
|
||||
double a, double b,
|
||||
double eps, int m, double *x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue