[arrayfire] 377/408: TEST: Adding tests for indexed reductions

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:12:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.

commit bce6967930002512997c82ac5398a0d93ea9b474
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Sep 2 14:29:04 2015 -0400

    TEST: Adding tests for indexed reductions
---
 test/ireduce.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++
 test/reduce.cpp  | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)

diff --git a/test/ireduce.cpp b/test/ireduce.cpp
index 18461c5..17abfcf 100644
--- a/test/ireduce.cpp
+++ b/test/ireduce.cpp
@@ -12,6 +12,7 @@
 #include <af/arith.h>
 #include <af/data.h>
 #include <testHelpers.hpp>
+#include <algorithm>
 
 using namespace std;
 using namespace af;
@@ -98,3 +99,47 @@ MINMAXOP(max, int)
 MINMAXOP(max, uint)
 MINMAXOP(max, char)
 MINMAXOP(max, uchar)
+
+TEST(ImaxAll, IndexedSmall)
+{
+    const int num = 1000;
+    const int st = 10;
+    const int en = num - 100;
+    af::array a = af::randu(num);
+
+    float b;
+    unsigned idx;
+    af::max<float>(&b, &idx, a(af::seq(st, en)));
+
+    std::vector<float> ha(num);
+    a.host(&ha[0]);
+
+    float res = ha[st];
+    for (int i = st; i <= en; i++) {
+        res = std::max(res, ha[i]);
+    }
+
+    ASSERT_EQ(b, res);
+}
+
+TEST(ImaxAll, IndexedBig)
+{
+    const int num = 100000;
+    const int st = 1000;
+    const int en = num - 1000;
+    af::array a = af::randu(num);
+
+    float b;
+    unsigned idx;
+    af::max<float>(&b, &idx, a(af::seq(st, en)));
+
+    std::vector<float> ha(num);
+    a.host(&ha[0]);
+
+    float res = ha[st];
+    for (int i = st; i <= en; i++) {
+        res = std::max(res, ha[i]);
+    }
+
+    ASSERT_EQ(b, res);
+}
diff --git a/test/reduce.cpp b/test/reduce.cpp
index ad99430..000f1ea 100644
--- a/test/reduce.cpp
+++ b/test/reduce.cpp
@@ -15,6 +15,7 @@
 #include <iostream>
 #include <string>
 #include <testHelpers.hpp>
+#include <algorithm>
 
 using std::vector;
 using std::string;
@@ -522,3 +523,41 @@ TEST(AnyAll, NaN)
     ASSERT_EQ(af::anyTrue<bool>(A), true);
     ASSERT_EQ(af::allTrue<bool>(A), false);
 }
+
+TEST(MaxAll, IndexedSmall)
+{
+    const int num = 1000;
+    const int st = 10;
+    const int en = num - 100;
+    af::array a = af::randu(num);
+    float b = af::max<float>(a(af::seq(st, en)));
+
+    std::vector<float> ha(num);
+    a.host(&ha[0]);
+
+    float res = ha[st];
+    for (int i = st; i <= en; i++) {
+        res = std::max(res, ha[i]);
+    }
+
+    ASSERT_EQ(b, res);
+}
+
+TEST(MaxAll, IndexedBig)
+{
+    const int num = 100000;
+    const int st = 1000;
+    const int en = num - 1000;
+    af::array a = af::randu(num);
+    float b = af::max<float>(a(af::seq(st, en)));
+
+    std::vector<float> ha(num);
+    a.host(&ha[0]);
+
+    float res = ha[st];
+    for (int i = st; i <= en; i++) {
+        res = std::max(res, ha[i]);
+    }
+
+    ASSERT_EQ(b, res);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list