[arrayfire] 203/248: Add support for c32/c64 for isInf, isNaN, iszero

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:54:27 UTC 2015


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

ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.

commit dc1bea35cb0e092130c002113106a4bf4e8d0869
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Thu Nov 5 11:41:00 2015 -0500

    Add support for c32/c64 for isInf, isNaN, iszero
---
 src/api/c/unary.cpp | 41 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/api/c/unary.cpp b/src/api/c/unary.cpp
index 3970128..a92df7b 100644
--- a/src/api/c/unary.cpp
+++ b/src/api/c/unary.cpp
@@ -20,6 +20,7 @@
 #include <unary.hpp>
 #include <implicit.hpp>
 #include <complex.hpp>
+#include <logic.hpp>
 #include <cast.hpp>
 #include <arith.hpp>
 
@@ -245,22 +246,58 @@ static inline af_array checkOp(const af_array in)
 }
 
 template<af_op_t op>
+struct cplxLogicOp
+{
+    af_array operator()(Array<char> resR, Array<char> resI, dim4 dims)
+    {
+        return getHandle(logicOp<char, af_or_t>(resR, resI, dims));
+    }
+};
+
+template <>
+struct cplxLogicOp<af_iszero_t>
+{
+    af_array operator()(Array<char> resR, Array<char> resI, dim4 dims)
+    {
+        return getHandle(logicOp<char, af_and_t>(resR, resI, dims));
+    }
+};
+
+template<typename T, typename BT, af_op_t op>
+static inline af_array checkOpCplx(const af_array in)
+{
+    Array<BT> R = real<BT, T>(getArray<T>(in));
+    Array<BT> I = imag<BT, T>(getArray<T>(in));
+
+    Array<char> resR = checkOp<BT, op>(R);
+    Array<char> resI = checkOp<BT, op>(I);
+
+    ArrayInfo in_info = getInfo(in);
+    dim4 dims = in_info.dims();
+    cplxLogicOp<op> cplxLogic;
+    af_array res = cplxLogic(resR, resI, dims);
+
+    return res;
+}
+
+template<af_op_t op>
 static af_err af_check(af_array *out, const af_array in)
 {
     try {
 
         ArrayInfo in_info = getInfo(in);
-        ARG_ASSERT(1, in_info.isReal());
 
         af_dtype in_type = in_info.getType();
         af_array res;
 
-        // Convert all inputs to floats / doubles
+        // Convert all inputs to floats / doubles / complex
         af_dtype type = implicit(in_type, f32);
 
         switch (type) {
         case f32 : res = checkOp<float  , op>(in); break;
         case f64 : res = checkOp<double , op>(in); break;
+        case c32 : res = checkOpCplx<cfloat , float , op>(in); break;
+        case c64 : res = checkOpCplx<cdouble, double, op>(in); break;
         default:
             TYPE_ERROR(1, in_type); break;
         }

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