[python-arrayfire] 214/250: Adding strides()

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:50 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 9bb9061783afcc628138339c972440a6a07f9345
Author: Filipe Maia <filipe.c.maia at gmail.com>
Date:   Sun Feb 14 00:25:27 2016 +0100

    Adding strides()
---
 arrayfire/array.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arrayfire/array.py b/arrayfire/array.py
index 4e98322..871d976 100644
--- a/arrayfire/array.py
+++ b/arrayfire/array.py
@@ -491,6 +491,24 @@ class Array(BaseArray):
         backend.get().af_get_raw_ptr(ct.pointer(ptr), self.arr)
         return ptr.value
 
+    def strides(self):
+        """
+        Return the distance in bytes between consecutive elements for each dimension.
+
+        Returns
+        ------
+        strides : tuple
+                  The strides for each dimension
+        """
+        s0 = ct.c_longlong(0)
+        s1 = ct.c_longlong(0)
+        s2 = ct.c_longlong(0)
+        s3 = ct.c_longlong(0)
+        safe_call(backend.get().af_get_strides(ct.pointer(s0), ct.pointer(s1),
+                                   ct.pointer(s2), ct.pointer(s3), self.arr))
+        strides = (s0.value,s1.value,s2.value,s3.value)
+        return strides[:self.numdims()]
+
     def elements(self):
         """
         Return the number of elements in the array.

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