summaryrefslogtreecommitdiff
path: root/orc-test
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2010-08-26 18:18:26 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-08-26 19:10:29 +0200
commit7f54b676cd2a6ebc434b40a107b4897f5cf41958 (patch)
treeeff19b3205a957d4250e02f96810c608872d0c49 /orc-test
parenta199d70c50a93449a90c55969fca5966dc790459 (diff)
Add support for comparing double arrays
Diffstat (limited to 'orc-test')
-rw-r--r--orc-test/orcarray.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/orc-test/orcarray.c b/orc-test/orcarray.c
index 05754f0..0686008 100644
--- a/orc-test/orcarray.c
+++ b/orc-test/orcarray.c
@@ -177,27 +177,47 @@ orc_array_set_pattern_2 (OrcArray *array, OrcRandomContext *context,
}
#define MIN_NONDENORMAL (1.1754944909521339405e-38)
+#define MIN_NONDENORMAL_D (2.2250738585072014e-308)
int
orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
{
- if ((flags & ORC_TEST_FLAGS_FLOAT) && array1->element_size == 4) {
- int j;
- for(j=0;j<array1->m;j++){
- float *a, *b;
- int i;
-
- a = ORC_PTR_OFFSET (array1->data, j*array1->stride);
- b = ORC_PTR_OFFSET (array2->data, j*array2->stride);
-
- for (i=0;i<array1->n;i++){
- if (isnan(a[i]) && isnan(b[i])) continue;
- if (a[i] == b[i]) continue;
- if (fabs(a[i] - b[i]) < MIN_NONDENORMAL) continue;
- return FALSE;
+ if ((flags & ORC_TEST_FLAGS_FLOAT)) {
+ if (array1->element_size == 4) {
+ int j;
+ for(j=0;j<array1->m;j++){
+ float *a, *b;
+ int i;
+
+ a = ORC_PTR_OFFSET (array1->data, j*array1->stride);
+ b = ORC_PTR_OFFSET (array2->data, j*array2->stride);
+
+ for (i=0;i<array1->n;i++){
+ if (isnan(a[i]) && isnan(b[i])) continue;
+ if (a[i] == b[i]) continue;
+ if (fabs(a[i] - b[i]) < MIN_NONDENORMAL) continue;
+ return FALSE;
+ }
+ }
+ return TRUE;
+ } else if (array1->element_size == 8) {
+ int j;
+ for(j=0;j<array1->m;j++){
+ double *a, *b;
+ int i;
+
+ a = ORC_PTR_OFFSET (array1->data, j*array1->stride);
+ b = ORC_PTR_OFFSET (array2->data, j*array2->stride);
+
+ for (i=0;i<array1->n;i++){
+ if (isnan(a[i]) && isnan(b[i])) continue;
+ if (a[i] == b[i]) continue;
+ if (abs(a[i] - b[i]) < MIN_NONDENORMAL_D) continue;
+ return FALSE;
+ }
}
+ return TRUE;
}
- return TRUE;
} else {
if (memcmp (array1->alloc_data, array2->alloc_data,
array1->alloc_len) == 0) {