[arrayfire] 99/408: TEST: Add mixed type tests with complex inputs

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:28 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 2ee28e7952ac396fa16d160de8e8cbd5181bec44
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Thu Jul 2 19:32:21 2015 -0400

    TEST: Add mixed type tests with complex inputs
---
 test/binary.cpp  | 18 +++++++++++++++---
 test/complex.cpp | 18 +++++++++---------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/test/binary.cpp b/test/binary.cpp
index f4e432f..73dbb3f 100644
--- a/test/binary.cpp
+++ b/test/binary.cpp
@@ -35,6 +35,8 @@ af::array randgen(const int num, af::dtype ty)
     return tmp;
 }
 
+#define MY_ASSERT_NEAR(aa, bb, cc) ASSERT_NEAR(abs(aa), abs(bb), (cc))
+
 #define BINARY_TESTS(Ta, Tb, Tc, func)                                  \
     TEST(BinaryTests, Test_##func##_##Ta##_##Tb)                        \
     {                                                                   \
@@ -111,7 +113,7 @@ af::array randgen(const int num, af::dtype ty)
         Tb *h_b = b.host<Tb>();                                         \
         Tc *h_c = c.host<Tc>();                                         \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_NEAR(h_c[i], func(h_a[i], h_b[i]), err) <<           \
+            MY_ASSERT_NEAR(h_c[i], func(h_a[i], h_b[i]), (err)) <<      \
                 "for values: " << h_a[i]  << "," << h_b[i] << std::endl; \
         delete[] h_a;                                                   \
         delete[] h_b;                                                   \
@@ -130,7 +132,7 @@ af::array randgen(const int num, af::dtype ty)
         Ta *h_a = a.host<Ta>();                                         \
         Ta *h_c = c.host<Ta>();                                         \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_NEAR(h_c[i], func(h_a[i], h_b), err) <<              \
+            MY_ASSERT_NEAR(h_c[i], func(h_a[i], h_b), err) <<           \
                 "for values: " << h_a[i]  << "," << h_b << std::endl;   \
         delete[] h_a;                                                   \
         delete[] h_c;                                                   \
@@ -149,7 +151,7 @@ af::array randgen(const int num, af::dtype ty)
         Tb *h_b = b.host<Tb>();                                         \
         Tb *h_c = c.host<Tb>();                                         \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_NEAR(h_c[i], func(h_a, h_b[i]), err) <<              \
+            MY_ASSERT_NEAR(h_c[i], func(h_a, h_b[i]), err) <<           \
                 "for values: " << h_a  << "," << h_b[i] << std::endl;   \
         delete[] h_b;                                                   \
         delete[] h_c;                                                   \
@@ -219,6 +221,16 @@ BINARY_TESTS_NEAR(float, double, double, sub, 1e-5)
 BINARY_TESTS_NEAR(float, double, double, mul, 1e-5)
 BINARY_TESTS_NEAR(float, double, double, div, 1e-5)
 
+BINARY_TESTS_NEAR(cfloat, cdouble, cdouble, add, 1e-5)
+BINARY_TESTS_NEAR(cfloat, cdouble, cdouble, sub, 1e-5)
+BINARY_TESTS_NEAR(cfloat, cdouble, cdouble, mul, 1e-5)
+BINARY_TESTS_NEAR(cfloat, cdouble, cdouble, div, 1e-5)
+
+BINARY_TESTS_NEAR(cfloat, double, cdouble, add, 1e-5)
+BINARY_TESTS_NEAR(cfloat, double, cdouble, sub, 1e-5)
+BINARY_TESTS_NEAR(cfloat, double, cdouble, mul, 1e-5)
+BINARY_TESTS_NEAR(cfloat, double, cdouble, div, 1e-5)
+
 #define BITOP(func, T, op)                                  \
     TEST(BinaryTests, Test_##func##_##T)                    \
     {                                                       \
diff --git a/test/complex.cpp b/test/complex.cpp
index 59e8ea2..6c60c4d 100644
--- a/test/complex.cpp
+++ b/test/complex.cpp
@@ -34,9 +34,9 @@ const int num = 10;
         af::array c = af::complex(a, b);                                \
         Ta *h_a = a.host<Ta>();                                         \
         Tb *h_b = b.host<Tb>();                                         \
-        CPLX(Tc) *h_c = c.host< CPLX(Tc) >();           \
+        CPLX(Tc) *h_c = c.host< CPLX(Tc) >();                           \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_EQ(h_c[i], CPLX(Tc)(h_a[i], h_b[i])) <<      \
+            ASSERT_EQ(h_c[i], CPLX(Tc)(h_a[i], h_b[i])) <<              \
                 "for values: " << h_a[i]  << "," << h_b[i] << std::endl; \
         delete[] h_a;                                                   \
         delete[] h_b;                                                   \
@@ -52,9 +52,9 @@ const int num = 10;
         Tb h_b = 0.3;                                                   \
         af::array c = af::complex(a, h_b);                              \
         Ta *h_a = a.host<Ta>();                                         \
-        CPLX(Ta) *h_c = c.host<CPLX(Ta) >();            \
+        CPLX(Ta) *h_c = c.host<CPLX(Ta) >();                            \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_EQ(h_c[i], CPLX(Ta)(h_a[i], h_b)) <<         \
+            ASSERT_EQ(h_c[i], CPLX(Ta)(h_a[i], h_b)) <<                 \
                 "for values: " << h_a[i]  << "," << h_b << std::endl;   \
         delete[] h_a;                                                   \
         delete[] h_c;                                                   \
@@ -70,9 +70,9 @@ const int num = 10;
         af::array b = randu(num, tb);                                   \
         af::array c = af::complex(h_a, b);                              \
         Tb *h_b = b.host<Tb>();                                         \
-        CPLX(Tb) *h_c = c.host<CPLX(Tb) >();            \
+        CPLX(Tb) *h_c = c.host<CPLX(Tb) >();                            \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_EQ(h_c[i], CPLX(Tb)(h_a, h_b[i])) <<         \
+            ASSERT_EQ(h_c[i], CPLX(Tb)(h_a, h_b[i])) <<                 \
                 "for values: " << h_a  << "," << h_b[i] << std::endl;   \
         delete[] h_b;                                                   \
         delete[] h_c;                                                   \
@@ -127,10 +127,10 @@ const int num = 10;
         af::array b = randu(num, tb);                                   \
         af::array c = af::complex(a, b);                                \
         af::array d = af::conjg(c);                                     \
-        CPLX(Tc) *h_c = c.host<CPLX(Tc) >();            \
-        CPLX(Tc) *h_d = d.host<CPLX(Tc) >();            \
+        CPLX(Tc) *h_c = c.host<CPLX(Tc) >();                            \
+        CPLX(Tc) *h_d = d.host<CPLX(Tc) >();                            \
         for (int i = 0; i < num; i++)                                   \
-            ASSERT_EQ(conj(h_c[i]), h_d[i])                        \
+            ASSERT_EQ(conj(h_c[i]), h_d[i])                             \
                 << "at: " << i << std::endl;                            \
         delete[] h_c;                                                   \
         delete[] h_d;                                                   \

-- 
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