commit 4649c018eece391c72410f47d7307ba5fdf39673
parent 528dead0f466c77cd8e821bfa4e5acfd73d678ef
Author: vaplv <vaplv@free.fr>
Date: Tue, 5 Jul 2016 11:24:37 +0200
Add and test the double<2|3|4> data types
Make generic the float<2|3|4> tests to the real type and use them to
test the double<2|3|4> data types.
Diffstat:
16 files changed, 499 insertions(+), 286 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -67,6 +67,9 @@ set(RSYS_FILES_INC_API
clock_time.h
condition.h
cstr.h
+ double2.h
+ double3.h
+ double4.h
dynamic_array.h
dynamic_array_char.h
dynamic_array_double.h
@@ -161,6 +164,9 @@ if(NOT NO_TEST)
new_test(test_atomic)
new_test(test_binary_heap rsys)
new_test(test_cstr rsys)
+ new_test(test_double2 ${MATH_LIB})
+ new_test(test_double3 ${MATH_LIB})
+ new_test(test_double4 ${MATH_LIB})
new_test(test_dynamic_array rsys)
new_test(test_float2 ${MATH_LIB})
new_test(test_float3 ${MATH_LIB})
diff --git a/src/double2.h b/src/double2.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef DOUBLE2_H
+#define DOUBLE2_H
+
+#define REAL_TYPE__ double
+#include "real2.h"
+
+#endif /* DOUBLE2_H */
+
diff --git a/src/double3.h b/src/double3.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef DOUBLE3_H
+#define DOUBLE3_H
+
+#define REAL_TYPE__ double
+#include "real3.h"
+
+#endif /* DOUBLE3_H */
+
diff --git a/src/double4.h b/src/double4.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef DOUBLE4_H
+#define DOUBLE4_H
+
+/* Generate common floatX funcs */
+#define REALX_DIMENSION__ 4
+#define REAL_TYPE__ double
+#include "realX_begin.h"
+#include "realX.h"
+#include "realX_end.h"
+
+#endif /* DOUBLE4_H */
+
diff --git a/src/realX.h b/src/realX.h
@@ -26,7 +26,7 @@
#if REALX_DIMENSION__ <= 4
static FINLINE REAL_TYPE__*
-CONCAT(REAL_LETTER__, REALX_DIMENSION__)
+REALX_CTOR__
(REAL_TYPE__* dst
,const REAL_TYPE__ x
,const REAL_TYPE__ y
@@ -142,7 +142,7 @@ REALX_FUNC__(add)
}
static FINLINE REAL_TYPE__*
-REALX_FUNC__(CONCAT(add, REAL_LETTER__))
+REALX_REAL_FUNC__(add)
(REAL_TYPE__* dst,
const REAL_TYPE__* a,
const REAL_TYPE__ f)
@@ -170,7 +170,7 @@ REALX_FUNC__(sub)
}
static FINLINE REAL_TYPE__*
-REALX_FUNC__(CONCAT(sub, REAL_LETTER__))
+REALX_REAL_FUNC__(sub)
(REAL_TYPE__* dst,
const REAL_TYPE__* a,
const REAL_TYPE__ f)
@@ -198,7 +198,7 @@ REALX_FUNC__(mul)
}
static FINLINE REAL_TYPE__*
-REALX_FUNC__(CONCAT(mul, REAL_LETTER__))
+REALX_REAL_FUNC__(mul)
(REAL_TYPE__* dst,
const REAL_TYPE__* a,
const REAL_TYPE__ f)
@@ -226,7 +226,7 @@ REALX_FUNC__(div)
}
static FINLINE REAL_TYPE__*
-REALX_FUNC__(CONCAT(div, REAL_LETTER__))
+REALX_REAL_FUNC__(div)
(REAL_TYPE__* dst,
const REAL_TYPE__* a,
const REAL_TYPE__ f)
diff --git a/src/realX_begin.h b/src/realX_begin.h
@@ -25,7 +25,9 @@
#endif
/* Check that internal macros are not already defined */
-#if defined(REALX_FUNC__) \
+#if defined(REALX_CTOR__) \
+ || defined(REALX_FUNC__) \
+ || defined(REALX_REAL_FUNC__) \
|| defined(REAL_LETTER__) \
|| defined(REAL_LETTER_float) \
|| defined(REAL_LETTER_double) \
@@ -58,6 +60,12 @@
#define REALX_FUNC__(Func) \
CONCAT(CONCAT(CONCAT(REAL_LETTER__, REALX_DIMENSION__), _), Func)
+/* Define the function name generator for the realX x real -> realX function */
+#define REALX_REAL_FUNC__(Func) CONCAT(REALX_FUNC__(Func), REAL_LETTER__)
+
+/* Define the realX constructor from reals */
+#define REALX_CTOR__ CONCAT(REAL_LETTER__, REALX_DIMENSION__)
+
/* Helper macro */
#define SIZEOF_REALX__ sizeof(REAL_TYPE__[REALX_DIMENSION__])
diff --git a/src/realX_end.h b/src/realX_end.h
@@ -29,7 +29,9 @@
#undef REAL_EQ_EPS__
#undef REAL_EQ_EPS_float
#undef REAL_EQ_EPS_double
+#undef REALX_CTOR__
#undef REALX_FUNC__
+#undef REALX_REAL_FUNC__
#undef SIZEOF_REALX__
#undef REALX_BEGIN_H
diff --git a/src/test_double2.c b/src/test_double2.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "double2.h"
+#define REAL_TYPE__ double
+#include "test_real2.h"
+
diff --git a/src/test_double3.c b/src/test_double3.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "double3.h"
+#define REAL_TYPE__ double
+#include "test_real3.h"
+
diff --git a/src/test_double4.c b/src/test_double4.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "double4.h"
+#define REAL_TYPE__ double
+#include "test_real4.h"
+
diff --git a/src/test_float2.c b/src/test_float2.c
@@ -14,92 +14,6 @@
* along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
#include "float2.h"
-#include "rsys.h"
-#include <float.h>
-
-#define CHECK_F2(a, b) \
- { \
- float* a__ = (a); \
- float* b__ = (b); \
- CHECK((a__)[0], (b__)[0]); \
- CHECK((a__)[1], (b__)[1]); \
- } (void) 0
-
-int
-main(int argc, char** argv)
-{
- float a[2], b[2], dst[2], f, c[2];
- (void)argc, (void)argv;
-
- f2_set(a, f2_splat(c, -1.f));
- CHECK_F2(a, c);
- CHECK(a[0], -1.f);
- CHECK(a[1], -1.f);
- f2_set(a, f2(c, 0.f, 1.f));
- CHECK(a[0], 0.f);
- CHECK(a[1], 1.f);
- f2_splat(a, -2.f);
- CHECK(a[0], -2.f);
- CHECK(a[1], -2.f);
-
- f2_set(a, f2(c, -1.f, 2.f));
- CHECK_F2(f2_minus(b, a), f2(c, 1.f, -2.f));
- CHECK_F2(b, f2(c, 1.f, -2.f));
-
- CHECK_F2(f2_addf(dst, a, 1.f), f2(c, 0.f, 3.f));
- CHECK_F2(dst, f2(c, 0.f, 3.f));
- CHECK_F2(f2_add(dst, a, b), f2_splat(c, 0.f));
- CHECK_F2(dst, f2_splat(c, 0.f));
- CHECK_F2(f2_subf(dst, a, 1.f), f2(c, -2.f, 1.f));
- CHECK_F2(dst, f2(c, -2.f, 1.f));
- CHECK_F2(f2_sub(dst, a, b), f2(c, -2.f, 4.f));
- CHECK_F2(dst, f2(c, -2.f, 4.f));
- CHECK_F2(f2_mulf(dst, a, 2.f), f2(c, -2.f, 4.f));
- CHECK_F2(dst, f2(c, -2.f, 4.f));
- CHECK_F2(f2_mul(dst, a, b), f2(c, -1.f, -4.f));
- CHECK_F2(dst, f2(c, -1.f, -4.f));
- CHECK_F2(f2_div(dst, dst, a), f2(c, 1.f, -2.f));
- CHECK_F2(dst, f2(c, 1.f, -2.f));
- CHECK_F2(f2_divf(dst, a, 2.f), f2(c, -0.5f, 1.f));
- CHECK_F2(dst, f2(c, -0.5f, 1.f));
-
- f2_set(a, f2(c, 0.f, 1.f));
- f2_set(b, f2(c, 1.f, 2.f));
- CHECK_F2(f2_lerp(dst, a, b, 0.5f), f2(c, 0.5f, 1.5f));
- CHECK_F2(dst, f2(c, 0.5f, 1.5f));
- CHECK(f2_sum(b), 3.f);
- CHECK(f2_dot(a, b), 2.f);
- CHECK(eq_epsf(f2_len(a), (float)sqrt(1.0f), FLT_EPSILON), 1);
-
- CHECK(f2_is_normalized(b), 0);
- f = f2_normalize(dst, b);
- CHECK(f2_is_normalized(b), 0);
- NCHECK(f2_is_normalized(dst), 0);
- CHECK(eq_epsf(f, (float)sqrt(5.f), FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[0], b[0] / f, FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[1], b[1] / f, FLT_EPSILON), 1);
-
- CHECK(f2_eq(a, a), 1);
- CHECK(f2_eq(a, b), 0);
- CHECK(f2_eq(a, f2(c, b[0], a[1])), 0);
- CHECK(f2_eq(a, f2(c, a[0], b[1])), 0);
-
- f2_set(b, a);
- f2_add(b, b, f2_splat(c, FLT_EPSILON * 0.5f));
- CHECK(f2_eq(a, b), 0);
- CHECK(f2_eq_eps(a, b, FLT_EPSILON), 1);
- CHECK(f2_eq_eps(a, b, FLT_EPSILON * 0.25f), 0);
-
- f2_set(a, f2(c, 1.f, -2.f));
- f2_set(b, f2(c, 3.f, 1.f));
- CHECK(f2_cross(a, b), 7.f);
-
- f2_set(a, f2(c, 1.f, -2.f));
- f2_set(b, f2(c, -3.f, 1.f));
- CHECK_F2(f2_max(dst, a, b), f2(c, 1.f, 1.f));
- CHECK_F2(dst, f2(c, 1.f, 1.f));
- CHECK_F2(f2_min(dst, a, b), f2(c, -3.f, -2.f));
- CHECK_F2(dst, f2(c, -3.f, -2.f));
- return 0;
-}
+#define REAL_TYPE__ float
+#include "test_real2.h"
diff --git a/src/test_float3.c b/src/test_float3.c
@@ -14,101 +14,6 @@
* along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
#include "float3.h"
-#include "rsys.h"
-#include <float.h>
-
-#define CHECK_F3(a, b) \
- { \
- float* a__ = (a); \
- float* b__ = (b); \
- CHECK((a__)[0], (b__)[0]); \
- CHECK((a__)[1], (b__)[1]); \
- CHECK((a__)[2], (b__)[2]); \
- } (void)0
-
-int
-main(int argc, char** argv)
-{
- float a[3], b[3], dst[3], f, c[3];
- (void)argc, (void)argv;
-
- f3_set(a, f3_splat(c, -1.f));
- CHECK(a[0], -1.f);
- CHECK(a[1], -1.f);
- CHECK(a[2], -1.f);
- f3_set(a, f3(c, 0.f, 1.f, 2.f));
- CHECK(a[0], 0.f);
- CHECK(a[1], 1.f);
- CHECK(a[2], 2.f);
- f3_splat(a, -2.f);
- CHECK(a[0], -2.f);
- CHECK(a[1], -2.f);
- CHECK(a[2], -2.f);
-
- f3_set(a, f3(c, -1.f, 2.f, -3.f));
- CHECK_F3(f3_minus(b, a), f3(c, 1.f, -2.f, 3.f));
- CHECK_F3(b, f3(c, 1.f, -2.f, 3.f));
-
- CHECK_F3(f3_add(dst, a, b), f3_splat(c, 0.f));
- CHECK_F3(dst, f3_splat(c, 0.f));
- CHECK_F3(f3_addf(dst, a, 1), f3(c, 0.f, 3.f, -2.f));
- CHECK_F3(dst, f3(c, 0.f, 3.f, -2.f));
- CHECK_F3(f3_sub(dst, a, b), f3(c, -2.f, 4.f, -6.f));
- CHECK_F3(dst, f3(c, -2.f, 4.f, -6.f));
- CHECK_F3(f3_subf(dst, a, 1), f3(c, -2.f, 1.f, -4.f));
- CHECK_F3(dst, f3(c, -2.f, 1.f, -4.f));
- CHECK_F3(f3_mulf(dst, a, 2), f3(c, -2.f, 4.f, -6.f));
- CHECK_F3(dst, f3(c, -2.f, 4.f, -6.f));
- CHECK_F3(f3_mul(dst, a, b), f3(c, -1.f, -4.f, -9.f));
- CHECK_F3(dst, f3(c, -1.f, -4.f, -9.f));
- CHECK_F3(f3_div(dst, dst, a), f3(c, 1.f, -2.f, 3.f));
- CHECK_F3(dst, f3(c, 1.f, -2.f, 3.f));
- CHECK_F3(f3_divf(dst, a, 2.f), f3(c, -0.5f, 1.f, -1.5f));
- CHECK_F3(dst, f3(c, -0.5f, 1.f, -1.5f));
-
- f3_set(a, f3(c, 0.f, 1.f, 2.f));
- f3_set(b, f3(c, 1.f, 2.f, -1.f));
- CHECK_F3(f3_lerp(dst, a, b, 0.5f), f3(c, 0.5f, 1.5f, 0.5f));
- CHECK_F3(dst, f3(c, 0.5f, 1.5f, 0.5f));
- CHECK(f3_sum(b), 2.f);
- CHECK(f3_dot(a, b), 0.f);
- CHECK(eq_epsf(f3_len(a), (float)sqrt(5.0), FLT_EPSILON), 1);
-
- CHECK(f3_is_normalized(a), 0);
- f = f3_normalize(dst, a);
- CHECK(f3_is_normalized(a), 0);
- NCHECK(f3_is_normalized(dst), 0);
- CHECK(eq_epsf(f, (float)sqrt(5.0), FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[0], a[0] / f, FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[1], a[1] / f, FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[2], a[2] / f, FLT_EPSILON), 1);
-
- CHECK(f3_eq(a, a), 1);
- CHECK(f3_eq(a, b), 0);
- CHECK(f3_eq(a, f3(c, b[0], a[1], a[2])), 0);
- CHECK(f3_eq(a, f3(c, a[0], b[1], a[2])), 0);
- CHECK(f3_eq(a, f3(c, a[0], a[1], b[2])), 0);
-
- f3_set(b, a);
- f3_add(b, b, f3_splat(c, FLT_EPSILON * 0.5f));
- CHECK(f3_eq(a, b), 0);
- CHECK(f3_eq_eps(a, b, FLT_EPSILON), 1);
- CHECK(f3_eq_eps(a, b, FLT_EPSILON * 0.25f), 0);
- f3_set(a, f3(c, 1.f, -2.f, 2.f));
- f3_set(b, f3(c, 3.f, 1.f, -1.5f));
- CHECK_F3(f3_cross(dst, a, b), f3(c, 1.f, 7.5f, 7.f));
- CHECK_F3(dst, f3(c, 1.f, 7.5f, 7.f));
-
- f3(a, 0.f, 1.f, 0.f);
- f3(b, 0.f, 0.f, 1.f);
- CHECK_F3(f3_cross(a, a, b), f3(c, 1.f, 0.f, 0.f));
-
- f3_set(a, f3(c, 1.f, -2.f, 1.5f));
- f3_set(b, f3(c, -3.f, 1.f, -1.5f));
- CHECK_F3(f3_max(dst, a, b), f3(c, 1.f, 1.f, 1.5f));
- CHECK_F3(dst, f3(c, 1.f, 1.f, 1.5f));
- CHECK_F3(f3_min(dst, a, b), f3(c, -3.f, -2.f, -1.5f));
- CHECK_F3(dst, f3(c, -3.f, -2.f, -1.5f));
- return 0;
-}
+#define REAL_TYPE__ float
+#include "test_real3.h"
diff --git a/src/test_float4.c b/src/test_float4.c
@@ -14,99 +14,6 @@
* along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
#include "float4.h"
-#include "rsys.h"
-#include <float.h>
+#define REAL_TYPE__ float
+#include "test_real4.h"
-#define CHECK_F4(a, b) \
- { \
- float* a__ = (a); \
- float* b__ = (b); \
- CHECK((a__)[0], (b__)[0]); \
- CHECK((a__)[1], (b__)[1]); \
- CHECK((a__)[2], (b__)[2]); \
- CHECK((a__)[3], (b__)[3]); \
- } (void) 0
-
-int
-main(int argc, char** argv)
-{
- float a[4], b[4], dst[4], f, c[4];
- (void)argc, (void)argv;
-
- f4_set(a, f4_splat(c, -1.f));
- CHECK(a[0], -1.f);
- CHECK(a[1], -1.f);
- CHECK(a[2], -1.f);
- CHECK(a[3], -1.f);
- f4_set(a, f4(c, 0.f, 1.f, 2.f, 3.f));
- CHECK(a[0], 0.f);
- CHECK(a[1], 1.f);
- CHECK(a[2], 2.f);
- CHECK(a[3], 3.f);
- f4_splat(a, -2.f);
- CHECK(a[0], -2.f);
- CHECK(a[1], -2.f);
- CHECK(a[2], -2.f);
- CHECK(a[3], -2.f);
-
- f4_set(a, f4(c, -1.f, 2.f, -3.f, 4.f));
- CHECK_F4(f4_minus(b, a), f4(c, 1.f, -2.f, 3.f, -4.f));
- CHECK_F4(b, f4(c, 1.f, -2.f, 3.f, -4.f));
-
- CHECK_F4(f4_add(dst, a, b), f4_splat(c, 0.f));
- CHECK_F4(dst, f4_splat(c, 0.f));
- CHECK_F4(f4_addf(dst, a, 1.f), f4(c, 0.f, 3.f, -2.f, 5.f));
- CHECK_F4(dst, f4(c, 0.f, 3.F, -2.f, 5.f));
- CHECK_F4(f4_sub(dst, a, b), f4(c, -2.f, 4.f, -6.f, 8.f));
- CHECK_F4(dst, f4(c, -2.f, 4.f, -6.f, 8.f));
- CHECK_F4(f4_subf(dst, a, 1.f), f4(c, -2.f, 1.f, -4.f, 3.f));
- CHECK_F4(dst, f4(c, -2.f, 1.f, -4.f, 3.f));
- CHECK_F4(f4_mulf(dst, a, 2.f), f4(c, -2.f, 4.f, -6.f, 8.f));
- CHECK_F4(dst, f4(c, -2.f, 4.f, -6.f, 8.f));
- CHECK_F4(f4_mul(dst, a, b), f4(c, -1.f, -4.f, -9.f, -16.f));
- CHECK_F4(dst, f4(c, -1.f, -4.f, -9.f, -16.f));
- CHECK_F4(f4_div(dst, dst, a), f4(c, 1.f, -2.f, 3.f, -4.f));
- CHECK_F4(dst, f4(c, 1.f, -2.f, 3.f, -4.f));
- CHECK_F4(f4_divf(dst, a, 2.f), f4(c, -0.5f, 1.f, -1.5f, 2.f));
- CHECK_F4(dst, f4(c, -0.5f, 1.f, -1.5f, 2.f));
-
- f4_set(a, f4(c, 0.f, 1.f, 2.f, 4.f));
- f4_set(b, f4(c, 1.f, 2.f, -1.f, 1.f));
- CHECK_F4(f4_lerp(dst, a, b, 0.5f), f4(c, 0.5f, 1.5f, 0.5f, 2.5f));
- CHECK_F4(dst, f4(c, 0.5f, 1.5f, 0.5f, 2.5f));
- CHECK(f4_sum(b), 3.f);
- CHECK(f4_dot(a, b), 4.f);
- CHECK(eq_epsf(f4_len(a), (float)sqrt(21.0), FLT_EPSILON), 1);
-
- f4_set(a, f4(c, 0.f, 4.f, 2.f, 3.f));
- CHECK(f4_is_normalized(a), 0);
- f = f4_normalize(dst, a);
- CHECK(f4_is_normalized(a), 0);
- NCHECK(f4_is_normalized(dst), 0);
- CHECK(eq_epsf(f, (float)sqrt(29.0), FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[0], a[0] / f, FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[1], a[1] / f, FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[2], a[2] / f, FLT_EPSILON), 1);
- CHECK(eq_epsf(dst[3], a[3] / f, FLT_EPSILON), 1);
-
- CHECK(f4_eq(a, a), 1);
- CHECK(f4_eq(a, b), 0);
- CHECK(f4_eq(a, f4(c, b[0], a[1], a[2], a[3])), 0);
- CHECK(f4_eq(a, f4(c, a[0], b[1], a[2], a[3])), 0);
- CHECK(f4_eq(a, f4(c, a[0], a[1], b[2], a[3])), 0);
- CHECK(f4_eq(a, f4(c, a[0], a[1], a[2], b[3])), 0);
-
- f4_set(b, a);
- f4_add(b, b, f4_splat(c, FLT_EPSILON * 0.5f));
- CHECK(f4_eq(a, b), 0);
- CHECK(f4_eq_eps(a, b, FLT_EPSILON), 1);
- CHECK(f4_eq_eps(a, b, FLT_EPSILON * 0.25f), 0);
-
- f4_set(a, f4(c, 1.f, 3.f, -2.f, 0.1f));
- f4_set(b, f4(c, -1.f, 3.1f, -2.1f, 1.f));
- CHECK_F4(f4_max(dst, a, b), f4(c, 1.f, 3.1f, -2.f, 1.f));
- CHECK_F4(dst, f4(c, 1.f, 3.1f, -2.f, 1.f));
- CHECK_F4(f4_min(dst, a, b), f4(c, -1.f, 3.f, -2.1f, 0.1f));
- CHECK_F4(dst, f4(c, -1.f, 3.f, -2.1f, 0.1f));
- return 0;
-}
diff --git a/src/test_real2.h b/src/test_real2.h
@@ -0,0 +1,109 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "rsys.h"
+#include <float.h>
+
+#define REALX_DIMENSION__ 2
+#include "realX_begin.h"
+#define REAL REAL_TYPE__
+
+#define CHECK_REAL2(a, b) \
+ { \
+ REAL* a__ = (a); \
+ REAL* b__ = (b); \
+ CHECK((a__)[0], (b__)[0]); \
+ CHECK((a__)[1], (b__)[1]); \
+ } (void) 0
+
+int
+main(int argc, char** argv)
+{
+ REAL a[2], b[2], dst[2], f, c[2];
+ (void)argc, (void)argv;
+
+ REALX_FUNC__(set)(a, REALX_FUNC__(splat)(c, -1.0));
+ CHECK_REAL2(a, c);
+ CHECK(a[0], -1.0);
+ CHECK(a[1], -1.0);
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 1.0));
+ CHECK(a[0], 0.0);
+ CHECK(a[1], 1.0);
+ REALX_FUNC__(splat)(a, -2.0);
+ CHECK(a[0], -2.0);
+ CHECK(a[1], -2.0);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, -1.0, 2.0));
+ CHECK_REAL2(REALX_FUNC__(minus)(b, a), REALX_CTOR__(c, 1.0, -2.0));
+ CHECK_REAL2(b, REALX_CTOR__(c, 1.0, -2.0));
+
+ CHECK_REAL2(REALX_REAL_FUNC__(add)(dst, a, 1.0), REALX_CTOR__(c, 0.0, 3.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, 0.0, 3.0));
+ CHECK_REAL2(REALX_FUNC__(add)(dst, a, b), REALX_FUNC__(splat)(c, 0.0));
+ CHECK_REAL2(dst, REALX_FUNC__(splat)(c, 0.0));
+ CHECK_REAL2(REALX_REAL_FUNC__(sub)(dst, a, 1.0), REALX_CTOR__(c, -2.0, 1.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, -2.0, 1.0));
+ CHECK_REAL2(REALX_FUNC__(sub)(dst, a, b), REALX_CTOR__(c, -2.0, 4.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, -2.0, 4.0));
+ CHECK_REAL2(REALX_REAL_FUNC__(mul)(dst, a, 2.0), REALX_CTOR__(c, -2.0, 4.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, -2.0, 4.0));
+ CHECK_REAL2(REALX_FUNC__(mul)(dst, a, b), REALX_CTOR__(c, -1.0, -4.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, -1.0, -4.0));
+ CHECK_REAL2(REALX_FUNC__(div)(dst, dst, a), REALX_CTOR__(c, 1.0, -2.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, 1.0, -2.0));
+ CHECK_REAL2(REALX_REAL_FUNC__(div)(dst, a, 2.0), REALX_CTOR__(c, -0.5, 1.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, -0.5, 1.0));
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 1.0));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, 1.0, 2.0));
+ CHECK_REAL2(REALX_FUNC__(lerp)(dst, a, b, 0.5), REALX_CTOR__(c, 0.5, 1.5));
+ CHECK_REAL2(dst, REALX_CTOR__(c, 0.5, 1.5));
+ CHECK(REALX_FUNC__(sum)(b), 3.0);
+ CHECK(REALX_FUNC__(dot)(a, b), 2.0);
+ CHECK(eq_eps(REALX_FUNC__(len)(a), sqrt(1.0), REAL_EPSILON__), 1);
+
+ CHECK(REALX_FUNC__(is_normalized)(b), 0);
+ f = REALX_FUNC__(normalize)(dst, b);
+ CHECK(REALX_FUNC__(is_normalized)(b), 0);
+ NCHECK(REALX_FUNC__(is_normalized)(dst), 0);
+ CHECK(eq_eps(f, sqrt(5.0), REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[0], b[0] / f, REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[1], b[1] / f, REAL_EPSILON__), 1);
+
+ CHECK(REALX_FUNC__(eq)(a, a), 1);
+ CHECK(REALX_FUNC__(eq)(a, b), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, b[0], a[1])), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, a[0], b[1])), 0);
+
+ REALX_FUNC__(set)(b, a);
+ REALX_FUNC__(add)(b, b, REALX_FUNC__(splat)(c, REAL_EPSILON__ * 0.5));
+ CHECK(REALX_FUNC__(eq)(a, b), 0);
+ CHECK(REALX_FUNC__(eq_eps)(a, b, REAL_EPSILON__), 1);
+ CHECK(REALX_FUNC__(eq_eps)(a, b, REAL_EPSILON__ * 0.25), 0);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 1.0, -2.0));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, 3.0, 1.0));
+ CHECK(REALX_FUNC__(cross)(a, b), 7.0);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 1.0, -2.0));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, -3.0, 1.0));
+ CHECK_REAL2(REALX_FUNC__(max)(dst, a, b), REALX_CTOR__(c, 1.0, 1.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, 1.0, 1.0));
+ CHECK_REAL2(REALX_FUNC__(min)(dst, a, b), REALX_CTOR__(c, -3.0, -2.0));
+ CHECK_REAL2(dst, REALX_CTOR__(c, -3.0, -2.0));
+ return 0;
+}
+#include "realX_end.h"
+
diff --git a/src/test_real3.h b/src/test_real3.h
@@ -0,0 +1,117 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "rsys.h"
+#include <float.h>
+
+#define REALX_DIMENSION__ 3
+#include "realX_begin.h"
+#define REAL REAL_TYPE__
+
+#define CHECK_REAL3(a, b) \
+ { \
+ REAL* a__ = (a); \
+ REAL* b__ = (b); \
+ CHECK((a__)[0], (b__)[0]); \
+ CHECK((a__)[1], (b__)[1]); \
+ CHECK((a__)[2], (b__)[2]); \
+ } (void)0
+
+int
+main(int argc, char** argv)
+{
+ REAL a[3], b[3], dst[3], f, c[3];
+ (void)argc, (void)argv;
+
+ REALX_FUNC__(set)(a, REALX_FUNC__(splat)(c, -1.0));
+ CHECK(a[0], -1.0);
+ CHECK(a[1], -1.0);
+ CHECK(a[2], -1.0);
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 1.0, 2.0));
+ CHECK(a[0], 0.0);
+ CHECK(a[1], 1.0);
+ CHECK(a[2], 2.0);
+ REALX_FUNC__(splat)(a, -2.0);
+ CHECK(a[0], -2.0);
+ CHECK(a[1], -2.0);
+ CHECK(a[2], -2.0);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, -1.0, 2.0, -3.0));
+ CHECK_REAL3(REALX_FUNC__(minus)(b, a), REALX_CTOR__(c, 1.0, -2.0, 3.0));
+ CHECK_REAL3(b, REALX_CTOR__(c, 1.0, -2.0, 3.0));
+
+ CHECK_REAL3(REALX_FUNC__(add)(dst, a, b), REALX_FUNC__(splat)(c, 0.0));
+ CHECK_REAL3(dst, REALX_FUNC__(splat)(c, 0.0));
+ CHECK_REAL3(REALX_REAL_FUNC__(add)(dst, a, 1), REALX_CTOR__(c, 0.0, 3.0, -2.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, 0.0, 3.0, -2.0));
+ CHECK_REAL3(REALX_FUNC__(sub)(dst, a, b), REALX_CTOR__(c, -2.0, 4.0, -6.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, -2.0, 4.0, -6.0));
+ CHECK_REAL3(REALX_REAL_FUNC__(sub)(dst, a, 1), REALX_CTOR__(c, -2.0, 1.0, -4.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, -2.0, 1.0, -4.0));
+ CHECK_REAL3(REALX_REAL_FUNC__(mul)(dst, a, 2), REALX_CTOR__(c, -2.0, 4.0, -6.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, -2.0, 4.0, -6.0));
+ CHECK_REAL3(REALX_FUNC__(mul)(dst, a, b), REALX_CTOR__(c, -1.0, -4.0, -9.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, -1.0, -4.0, -9.0));
+ CHECK_REAL3(REALX_FUNC__(div)(dst, dst, a), REALX_CTOR__(c, 1.0, -2.0, 3.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, 1.0, -2.0, 3.0));
+ CHECK_REAL3(REALX_REAL_FUNC__(div)(dst, a, 2.0), REALX_CTOR__(c, -0.5, 1.0, -1.5));
+ CHECK_REAL3(dst, REALX_CTOR__(c, -0.5, 1.0, -1.5));
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 1.0, 2.0));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, 1.0, 2.0, -1.0));
+ CHECK_REAL3(REALX_FUNC__(lerp)(dst, a, b, 0.5), REALX_CTOR__(c, 0.5, 1.5, 0.5));
+ CHECK_REAL3(dst, REALX_CTOR__(c, 0.5, 1.5, 0.5));
+ CHECK(REALX_FUNC__(sum)(b), 2.0);
+ CHECK(REALX_FUNC__(dot)(a, b), 0.0);
+ CHECK(eq_eps(REALX_FUNC__(len)(a), sqrt(5.0), REAL_EPSILON__), 1);
+
+ CHECK(REALX_FUNC__(is_normalized)(a), 0);
+ f = REALX_FUNC__(normalize)(dst, a);
+ CHECK(REALX_FUNC__(is_normalized)(a), 0);
+ NCHECK(REALX_FUNC__(is_normalized)(dst), 0);
+ CHECK(eq_eps(f, sqrt(5.0), REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[0], a[0] / f, REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[1], a[1] / f, REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[2], a[2] / f, REAL_EPSILON__), 1);
+
+ CHECK(REALX_FUNC__(eq)(a, a), 1);
+ CHECK(REALX_FUNC__(eq)(a, b), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, b[0], a[1], a[2])), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, a[0], b[1], a[2])), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, a[0], a[1], b[2])), 0);
+
+ REALX_FUNC__(set)(b, a);
+ REALX_FUNC__(add)(b, b, REALX_FUNC__(splat)(c, REAL_EPSILON__ * 0.5));
+ CHECK(REALX_FUNC__(eq)(a, b), 0);
+ CHECK(REALX_FUNC__(eq_eps)(a, b, REAL_EPSILON__), 1);
+ CHECK(REALX_FUNC__(eq_eps)(a, b, REAL_EPSILON__ * 0.25), 0);
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 1.0, -2.0, 2.0));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, 3.0, 1.0, -1.5));
+ CHECK_REAL3(REALX_FUNC__(cross)(dst, a, b), REALX_CTOR__(c, 1.0, 7.5, 7.0));
+ CHECK_REAL3(dst, REALX_CTOR__(c, 1.0, 7.5, 7.0));
+
+ REALX_CTOR__(a, 0.0, 1.0, 0.0);
+ REALX_CTOR__(b, 0.0, 0.0, 1.0);
+ CHECK_REAL3(REALX_FUNC__(cross)(a, a, b), REALX_CTOR__(c, 1.0, 0.0, 0.0));
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 1.0, -2.0, 1.5));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, -3.0, 1.0, -1.5));
+ CHECK_REAL3(REALX_FUNC__(max)(dst, a, b), REALX_CTOR__(c, 1.0, 1.0, 1.5));
+ CHECK_REAL3(dst, REALX_CTOR__(c, 1.0, 1.0, 1.5));
+ CHECK_REAL3(REALX_FUNC__(min)(dst, a, b), REALX_CTOR__(c, -3.0, -2.0, -1.5));
+ CHECK_REAL3(dst, REALX_CTOR__(c, -3.0, -2.0, -1.5));
+ return 0;
+}
+
diff --git a/src/test_real4.h b/src/test_real4.h
@@ -0,0 +1,115 @@
+/* Copyright (C) 2013-2016 Vincent Forest (vaplv@free.fr)
+ *
+ * The RSys library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The RSys library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "rsys.h"
+#include <float.h>
+
+#define REALX_DIMENSION__ 4
+#include "realX_begin.h"
+#define REAL REAL_TYPE__
+
+#define CHECK_REAL4(a, b) \
+ { \
+ REAL* a__ = (a); \
+ REAL* b__ = (b); \
+ CHECK((a__)[0], (b__)[0]); \
+ CHECK((a__)[1], (b__)[1]); \
+ CHECK((a__)[2], (b__)[2]); \
+ CHECK((a__)[3], (b__)[3]); \
+ } (void) 0
+
+int
+main(int argc, char** argv)
+{
+ REAL a[4], b[4], dst[4], f, c[4];
+ (void)argc, (void)argv;
+
+ REALX_FUNC__(set)(a, REALX_FUNC__(splat)(c, -1.0));
+ CHECK(a[0], -1.0);
+ CHECK(a[1], -1.0);
+ CHECK(a[2], -1.0);
+ CHECK(a[3], -1.0);
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 1.0, 2.0, 3.0));
+ CHECK(a[0], 0.0);
+ CHECK(a[1], 1.0);
+ CHECK(a[2], 2.0);
+ CHECK(a[3], 3.0);
+ REALX_FUNC__(splat)(a, -2.0);
+ CHECK(a[0], -2.0);
+ CHECK(a[1], -2.0);
+ CHECK(a[2], -2.0);
+ CHECK(a[3], -2.0);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, -1.0, 2.0, -3.0, 4.0));
+ CHECK_REAL4(REALX_FUNC__(minus)(b, a), REALX_CTOR__(c, 1.0, -2.0, 3.0, -4.0));
+ CHECK_REAL4(b, REALX_CTOR__(c, 1.0, -2.0, 3.0, -4.0));
+
+ CHECK_REAL4(REALX_FUNC__(add)(dst, a, b), REALX_FUNC__(splat)(c, 0.0));
+ CHECK_REAL4(dst, REALX_FUNC__(splat)(c, 0.0));
+ CHECK_REAL4(REALX_REAL_FUNC__(add)(dst, a, 1.0), REALX_CTOR__(c, 0.0, 3.0, -2.0, 5.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, 0.0, 3.F, -2.0, 5.0));
+ CHECK_REAL4(REALX_FUNC__(sub)(dst, a, b), REALX_CTOR__(c, -2.0, 4.0, -6.0, 8.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, -2.0, 4.0, -6.0, 8.0));
+ CHECK_REAL4(REALX_REAL_FUNC__(sub)(dst, a, 1.0), REALX_CTOR__(c, -2.0, 1.0, -4.0, 3.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, -2.0, 1.0, -4.0, 3.0));
+ CHECK_REAL4(REALX_REAL_FUNC__(mul)(dst, a, 2.0), REALX_CTOR__(c, -2.0, 4.0, -6.0, 8.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, -2.0, 4.0, -6.0, 8.0));
+ CHECK_REAL4(REALX_FUNC__(mul)(dst, a, b), REALX_CTOR__(c, -1.0, -4.0, -9.0, -16.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, -1.0, -4.0, -9.0, -16.0));
+ CHECK_REAL4(REALX_FUNC__(div)(dst, dst, a), REALX_CTOR__(c, 1.0, -2.0, 3.0, -4.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, 1.0, -2.0, 3.0, -4.0));
+ CHECK_REAL4(REALX_REAL_FUNC__(div)(dst, a, 2.0), REALX_CTOR__(c, -0.5, 1.0, -1.5, 2.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, -0.5, 1.0, -1.5, 2.0));
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 1.0, 2.0, 4.0));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, 1.0, 2.0, -1.0, 1.0));
+ CHECK_REAL4(REALX_FUNC__(lerp)(dst, a, b, 0.5), REALX_CTOR__(c, 0.5, 1.5, 0.5, 2.5));
+ CHECK_REAL4(dst, REALX_CTOR__(c, 0.5, 1.5, 0.5, 2.5));
+ CHECK(REALX_FUNC__(sum)(b), 3.0);
+ CHECK(REALX_FUNC__(dot)(a, b), 4.0);
+ CHECK(eq_eps(REALX_FUNC__(len)(a), sqrt(21.0), REAL_EPSILON__), 1);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 0.0, 4.0, 2.0, 3.0));
+ CHECK(REALX_FUNC__(is_normalized)(a), 0);
+ f = REALX_FUNC__(normalize)(dst, a);
+ CHECK(REALX_FUNC__(is_normalized)(a), 0);
+ NCHECK(REALX_FUNC__(is_normalized)(dst), 0);
+ CHECK(eq_eps(f, sqrt(29.0), REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[0], a[0] / f, REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[1], a[1] / f, REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[2], a[2] / f, REAL_EPSILON__), 1);
+ CHECK(eq_eps(dst[3], a[3] / f, REAL_EPSILON__), 1);
+
+ CHECK(REALX_FUNC__(eq)(a, a), 1);
+ CHECK(REALX_FUNC__(eq)(a, b), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, b[0], a[1], a[2], a[3])), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, a[0], b[1], a[2], a[3])), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, a[0], a[1], b[2], a[3])), 0);
+ CHECK(REALX_FUNC__(eq)(a, REALX_CTOR__(c, a[0], a[1], a[2], b[3])), 0);
+
+ REALX_FUNC__(set)(b, a);
+ REALX_FUNC__(add)(b, b, REALX_FUNC__(splat)(c, REAL_EPSILON__ * 0.5));
+ CHECK(REALX_FUNC__(eq)(a, b), 0);
+ CHECK(REALX_FUNC__(eq_eps)(a, b, REAL_EPSILON__), 1);
+ CHECK(REALX_FUNC__(eq_eps)(a, b, REAL_EPSILON__ * 0.25), 0);
+
+ REALX_FUNC__(set)(a, REALX_CTOR__(c, 1.0, 3.0, -2.0, (REAL)0.1));
+ REALX_FUNC__(set)(b, REALX_CTOR__(c, -1.0, (REAL)3.1, (REAL)-2.1, 1.0));
+ CHECK_REAL4(REALX_FUNC__(max)(dst, a, b), REALX_CTOR__(c, 1.0, (REAL)3.1, -2.0, (REAL)1.0));
+ CHECK_REAL4(dst, REALX_CTOR__(c, 1.0, (REAL)3.1, -2.0, 1.0));
+ CHECK_REAL4(REALX_FUNC__(min)(dst, a, b), REALX_CTOR__(c, -1.0, 3.0, (REAL)-2.1, (REAL)0.1));
+ CHECK_REAL4(dst, REALX_CTOR__(c, -1.0, 3.0, (REAL)-2.1, (REAL)0.1));
+ return 0;
+}