25#define _USE_MATH_DEFINES
41static const double dbl_min_e_exp = (DBL_MIN_EXP - 1) * log(
double(FLT_RADIX));
42static const double dbl_max_e_exp = (DBL_MAX_EXP - 1) * log(
double(FLT_RADIX));
43static const double dbl_max_square =
sqrt(DBL_MAX);
45static const double dbl_max_pow3 =
pow(DBL_MAX, 1.0 / 3.0);
48static const double flt_min_e_exp = (FLT_MIN_EXP - 1) * log(
double(FLT_RADIX));
49static const double flt_max_e_exp = (FLT_MAX_EXP - 1) * log(
double(FLT_RADIX));
50static const double flt_max_square =
sqrt(FLT_MAX);
52static const double flt_max_pow3 =
53 pow(FLT_MAX,
float(1.0 / 3.0));
90inline double find_min(
double a,
double b) {
return (a < b ? a : b); }
91inline double find_max(
double a,
double b) {
return (a > b ? a : b); }
92inline float find_min(
float a,
float b) {
return (a < b ? a : b); }
93inline float find_max(
float a,
float b) {
return (a > b ? a : b); }
94inline long find_min(
long a,
long b) {
return (a < b ? a : b); }
95inline long find_max(
long a,
long b) {
return (a > b ? a : b); }
96inline int find_min(
int a,
int b) {
return (a < b ? a : b); }
97inline int find_max(
int a,
int b) {
return (a > b ? a : b); }
103 return -long(-f) - 1;
115 return ((val > b1 && val < b2) ? 1 : 0);
118 return ((val > b1 && val < b2) ? 1 : 0);
121 return ((val > b1 && val < b2) ? 1 : 0);
124 return ((val > b1 && val < b2) ? 1 : 0);
128 return ((val >= b1 && val <= b2) ? 1 : 0);
131 return ((val >= b1 && val <= b2) ? 1 : 0);
134 return ((val >= b1 && val <= b2) ? 1 : 0);
137 return ((val >= b1 && val <= b2) ? 1 : 0);
141 return ((val > b[0] && val < b[1]) ? 1 : 0);
144 return ((val > b[0] && val < b[1]) ? 1 : 0);
147 return ((val > b[0] && val < b[1]) ? 1 : 0);
150 return ((val > b[0] && val < b[1]) ? 1 : 0);
154 return ((val >= b[0] && val <= b[1]) ? 1 : 0);
157 return ((val >= b[0] && val <= b[1]) ? 1 : 0);
160 return ((val >= b[0] && val <= b[1]) ? 1 : 0);
163 return ((val >= b[0] && val <= b[1]) ? 1 : 0);
176template <
class T>
inline void fcopy(T ar_source, T ar_dest,
long q) {
177 for (
long n = 0; n < q; ++n)
178 ar_dest[n] = ar_source[n];
182inline void arr_copy(
const T* ar_source, T* ar_dest,
long q) {
183 for (
long n = 0; n < q; ++n)
184 ar_dest[n] = ar_source[n];
187template <
class T>
inline void arr_assign(
const T source, T* ar_dest,
long q) {
188 for (
long n = 0; n < q; ++n)
192template <
class T>
inline long fmax_ar(T ar,
long q) {
194 mcerr <<
"inline long fmax_ar(T ar, long q): q<=0\n";
198 for (
long n = 1; n < q; ++n) {
199 if (ar[n] > ar[nmval]) nmval = n;
204template <
class T>
inline T
tabs(
const T& x) {
return x >= 0 ? x : -x; }
206template <
class T>
int apeq_mant(
const T& x1,
const T& x2, T prec) {
207 if (x1 == x2)
return 1;
208 if (prec == 0)
return 0;
209 if (x1 == 0 && x2 == 0)
return 1;
210 if ((x1 < 0 && x2 > 0) || (x1 > 0 && x2 < 0))
return 0;
211 if (
tabs((x1 - x2) / (x1 + x2)) <= prec)
return 1;
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc sqrt(const DoubleAc &f)
double find_min(double a, double b)
long left_round(double f)
int check_value_in_bounds(double val, double b1, double b2)
int apeq_mant(const T &x1, const T &x2, T prec)
int check_value_inside_bounds(double val, double b1, double b2)
long fmax_ar(T ar, long q)
void arr_copy(const T *ar_source, T *ar_dest, long q)
double find_max(double a, double b)
void arr_assign(const T source, T *ar_dest, long q)
void fcopy(T ar_source, T ar_dest, long q)