commit 528dead0f466c77cd8e821bfa4e5acfd73d678ef
parent 32de987f38ce71b0478738fd9c7632f0dc3f15a5
Author: vaplv <vaplv@free.fr>
Date: Tue, 5 Jul 2016 09:51:07 +0200
Use the appropriate eq_eps function for the realX types
Diffstat:
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/realX.h b/src/realX.h
@@ -124,7 +124,7 @@ REALX_FUNC__(normalize)(REAL_TYPE__* dst, const REAL_TYPE__* a)
static FINLINE char
REALX_FUNC__(is_normalized)(const REAL_TYPE__* a)
{
- return eq_epsf(REALX_FUNC__(len)(a), 1.0, REAL_EPSILON__);
+ return REAL_EQ_EPS__(REALX_FUNC__(len)(a), (REAL_TYPE__)1.0, REAL_EPSILON__);
}
static FINLINE REAL_TYPE__*
@@ -308,7 +308,7 @@ REALX_FUNC__(eq_eps)
char is_eq = 1;
ASSERT(a && b);
do {
- is_eq = eq_epsf(a[i], b[i], eps);
+ is_eq = REAL_EQ_EPS__(a[i], b[i], eps);
++i;
} while(i < REALX_DIMENSION__ && is_eq);
return is_eq;
diff --git a/src/realX_begin.h b/src/realX_begin.h
@@ -32,6 +32,9 @@
|| defined(REAL_EPSILON__) \
|| defined(REAL_EPSILON_float) \
|| defined(REAL_EPSILON_double) \
+ || defined(REAL_EQ_EPS__) \
+ || defined(REAL_EQ_EPS_float) \
+ || defined(REAL_EQ_EPS_double) \
|| defined(SIZEOF_REALX__)
#error Unexpected macro definition
#endif
@@ -41,6 +44,11 @@
#define REAL_EPSILON_float 1.e-6f
#define REAL_EPSILON__ CONCAT(REAL_EPSILON_, REAL_TYPE__)
+/* Define the eq_eps function for each type */
+#define REAL_EQ_EPS_double eq_eps
+#define REAL_EQ_EPS_float eq_epsf
+#define REAL_EQ_EPS__ CONCAT(REAL_EQ_EPS_, REAL_TYPE__)
+
/* Define the suffix/prefix letter for each real type */
#define REAL_LETTER_float f
#define REAL_LETTER_double d
diff --git a/src/realX_end.h b/src/realX_end.h
@@ -26,6 +26,9 @@
#undef REAL_EPSILON__
#undef REAL_EPSILON_float
#undef REAL_EPSILON_double
+#undef REAL_EQ_EPS__
+#undef REAL_EQ_EPS_float
+#undef REAL_EQ_EPS_double
#undef REALX_FUNC__
#undef SIZEOF_REALX__