-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon_utils.h
More file actions
33 lines (25 loc) · 1.19 KB
/
common_utils.h
File metadata and controls
33 lines (25 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef PD_ASSERT_H
#define PD_ASSERT_H
#include <cassert>
#ifdef DEBUG
#define PDASSERT(cond) \
do { \
assert(cond); \
} while(false)
#else
#define PDASSERT(cond) static_cast<void>(0)
#endif
#define PI ((double) 3.1415926535897932384626433)
#define PDLN_ABS_TOLERANCE_LOW ((double) 1e-10)
#define PDLN_ABS_TOLERANCE ((double) 1e-10) // if less than 1e-10, will three point in a line, if more than 1e-15, will not pass check
#define PDLN_ABS_TOLERANCE_HI ((double) 1e-11) // normal grid less than 1e-11
#define PDLN_RELATIVE_TOLERANCE_LOW ((double) 1e-3)
#define PDLN_RELATIVE_TOLERANCE ((double) 1e-4)
#define PDLN_RELATIVE_TOLERANCE_HI ((double) 1e-5)
#define float_eq_low(a, b) (fabs(a - b) <= PDLN_ABS_TOLERANCE_LOW)
#define float_eq(a, b) (fabs(a - b) <= PDLN_ABS_TOLERANCE)
#define float_eq_hi(a, b) (fabs(a - b) <= PDLN_ABS_TOLERANCE_HI)
#define float_relative_eq_low(a, b) (fabs((double)a - (double)b)/(double)a <= PDLN_RELATIVE_TOLERANCE_LOW)
#define float_relative_eq(a, b) (fabs((double)a - (double)b)/(double)a <= PDLN_RELATIVE_TOLERANCE)
#define float_relative_eq_hi(a, b) (fabs((double)a - (double)b)/(double)a <= PDLN_RELATIVE_TOLERANCE_HI)
#endif