[python-arrayfire] 19/250: Adding blas functions and simple tests

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:26 UTC 2016


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

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

commit 7a3bbb8a0d79290f086ad0d42f91d8f8e58ae0b3
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Mon Jun 22 10:47:11 2015 -0400

    Adding blas functions and simple tests
---
 arrayfire/__init__.py  |  1 +
 arrayfire/algorithm.py |  1 -
 arrayfire/blas.py      | 22 ++++++++++++++++++++++
 tests/simple_blas.py   | 17 +++++++++++++++++
 4 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/arrayfire/__init__.py b/arrayfire/__init__.py
index 357f33f..816cae2 100644
--- a/arrayfire/__init__.py
+++ b/arrayfire/__init__.py
@@ -3,3 +3,4 @@ from .data import *
 from .util import *
 from .algorithm import *
 from .device import *
+from .blas import *
diff --git a/arrayfire/algorithm.py b/arrayfire/algorithm.py
index 3da47f8..cbe10a6 100644
--- a/arrayfire/algorithm.py
+++ b/arrayfire/algorithm.py
@@ -1,7 +1,6 @@
 from .library import *
 from .array import *
 
-
 def parallel_dim(a, dim, c_func):
     out = array()
     safe_call(c_func(pointer(out.arr), a.arr, c_int(dim)))
diff --git a/arrayfire/blas.py b/arrayfire/blas.py
new file mode 100644
index 0000000..e302f01
--- /dev/null
+++ b/arrayfire/blas.py
@@ -0,0 +1,22 @@
+from .library import *
+from .array import *
+
+def matmul(lhs, rhs, lhs_opts=AF_MAT_NONE, rhs_opts=AF_MAT_NONE):
+    out = array()
+    safe_call(clib.af_matmul(pointer(out.arr), lhs.arr, rhs.arr,\
+                             lhs_opts, rhs_opts))
+    return out
+
+def dot(lhs, rhs, lhs_opts=AF_MAT_NONE, rhs_opts=AF_MAT_NONE):
+    out = array()
+    safe_call(clib.af_dot(pointer(out.arr), lhs.arr, rhs.arr,\
+                          lhs_opts, rhs_opts))
+    return out
+
+def transpose(a, conj=False):
+    out = array()
+    safe_call(clib.af_transpose(pointer(out.arr), a.arr, conj))
+    return out
+
+def transpose_inplace(a, conj=False):
+    safe_call(clib.af_transpose_inplace(a.arr, conj))
diff --git a/tests/simple_blas.py b/tests/simple_blas.py
new file mode 100644
index 0000000..d6094de
--- /dev/null
+++ b/tests/simple_blas.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+import arrayfire as af
+
+a = af.randu(5,5)
+b = af.randu(5,5)
+
+af.print_array(af.matmul(a,b))
+af.print_array(af.matmul(a,b,af.AF_MAT_TRANS))
+af.print_array(af.matmul(a,b,af.AF_MAT_NONE, af.AF_MAT_TRANS))
+
+b = af.randu(5,1)
+af.print_array(af.dot(a,b))
+
+af.print_array(af.transpose(a))
+
+af.transpose_inplace(a)
+af.print_array(a)

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



More information about the debian-science-commits mailing list