blob: 546465e0468675573f4947be0ffcf834e8e8e5c0 [file] [log] [blame] [edit]
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
/*
#ifdef __cplusplus
extern "C" {
#endif
static inline bool approx_fp_equality_float(float f1, float f2, double threshold) {
if (fabs(f1-f2) > threshold) return false;
return true;
}
static inline bool approx_fp_equality_double(double f1, double f2, double threshold) {
if (fabs(f1-f2) > threshold) return false;
return true;
}
#ifdef __cplusplus
}
#endif
*/
#define APPROX_EQ(LHS, RHS, THRES) \
{ \
if (__builtin_fabs(LHS - RHS) > THRES) { \
fprintf(stderr, "Assertion Failed: fabs( [%s = %g] - [%s = %g] ) > %g at %s:%d (%s)\n", #LHS, LHS, #RHS, RHS, THRES, \
__FILE__, __LINE__, __PRETTY_FUNCTION__); \
abort(); \
} \
};