[python-arrayfire] 34/58: initial v34 api additions to python wrapper
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Sep 28 13:57:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository python-arrayfire.
commit a796a89e7aeb3d654296e1d6882df197353843f1
Author: syurkevi <stefan at arrayfire.com>
Date: Tue Jul 5 18:05:22 2016 -0400
initial v34 api additions to python wrapper
---
arrayfire/algorithm.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
arrayfire/image.py | 22 +++++++++++++++++++
arrayfire/library.py | 19 +++++++++++++++++
arrayfire/signal.py | 12 +++++++++++
4 files changed, 110 insertions(+)
diff --git a/arrayfire/algorithm.py b/arrayfire/algorithm.py
index 6701d96..50c9b61 100644
--- a/arrayfire/algorithm.py
+++ b/arrayfire/algorithm.py
@@ -299,6 +299,63 @@ def accum(a, dim=0):
"""
return _parallel_dim(a, dim, backend.get().af_accum)
+def scan(a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
+ """
+ Generalized scan of an array.
+
+ Parameters
+ ----------
+ a : af.Array
+ Multi dimensional arrayfire array.
+
+ dim : optional: int. default: 0
+ Dimension along which the scan is performed.
+
+ op : optional: af.BINARYOP. default: af.BINARYOP.BINARY_ADD.
+ - Interpolation method used for resizing.
+
+ inclusive_scan: optional: bool. default: True
+ Specifies if the scan is inclusive
+
+ Returns
+ ---------
+ out : af.Array
+ - will contain scan of input.
+ """
+ out = Array()
+ safe_call(backend.get().af_scan(ct.pointer(out.arr), a.arr, dim, op, inclusive_scan))
+ return out
+
+def scan_by_key(key, a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
+ """
+ Generalized scan by key of an array.
+
+ Parameters
+ ----------
+ key : af.Array
+ key array.
+
+ a : af.Array
+ Multi dimensional arrayfire array.
+
+ dim : optional: int. default: 0
+ Dimension along which the scan is performed.
+
+ op : optional: af.BINARYOP. default: af.BINARYOP.BINARY_ADD.
+ - Interpolation method used for resizing.
+
+ inclusive_scan: optional: bool. default: True
+ Specifies if the scan is inclusive
+
+ Returns
+ ---------
+ out : af.Array
+ - will contain scan of input.
+ """
+ out = Array()
+ safe_call(backend.get().af_scan_by_key(ct.pointer(out.arr), key.arr, a.arr, dim, op, inclusive_scan))
+ return out
+
def where(a):
"""
Find the indices of non zero elements
diff --git a/arrayfire/image.py b/arrayfire/image.py
index ac4b8ed..94a424a 100644
--- a/arrayfire/image.py
+++ b/arrayfire/image.py
@@ -1198,6 +1198,28 @@ def rgb2ycbcr(image, standard=YCC_STD.BT_601):
safe_call(backend.get().af_rgb2ycbcr(ct.pointer(out.arr), image.arr, standard.value))
return out
+def moments(image, moment = MOMENT.MOMENT_FIRST_ORDER):
+ """
+ Calculate image moments.
+
+ Parameters
+ ----------
+ image : af.Array
+ - A 2 D arrayfire array representing an image, or
+ - A multi dimensional array representing batch of images.
+
+ moment : optional: af.MOMENT. default: af.MOMENT.MOMENT_FIRST_ORDER.
+ - Moment(s) to calculate
+
+ Returns
+ ---------
+ out : af.Array
+ - array containing requested moment(s) of each image
+ """
+ output = Array()
+ safe_call(backend.get().af_moments(ct.pointer(output.arr), image.arr, moment.value))
+ return output
+
def is_image_io_available():
"""
Function to check if the arrayfire library was built with Image IO support.
diff --git a/arrayfire/library.py b/arrayfire/library.py
index ff09f05..79aa823 100644
--- a/arrayfire/library.py
+++ b/arrayfire/library.py
@@ -349,6 +349,25 @@ class MARKER(_Enum):
PLUS = _Enum_Type(6)
STAR = _Enum_Type(7)
+class MOMENT(_Enum):
+ """
+ Image Moments
+ """
+ MOMENT_M00 = _Enum_Type(1)
+ MOMENT_M01 = _Enum_Type(2)
+ MOMENT_M10 = _Enum_Type(4)
+ MOMENT_M11 = _Enum_Type(8)
+ MOMENT_FIRST_ORDER = _Enum_Type(15)
+
+class BINARYOP(_Enum):
+ """
+ Binary Operators
+ """
+ BINARY_ADD = _Enum_Type(0)
+ BINARY_MUL = _Enum_Type(1)
+ BINARY_MIN = _Enum_Type(2)
+ BINARY_MAX = _Enum_Type(3)
+
def _setup():
import platform
import os
diff --git a/arrayfire/signal.py b/arrayfire/signal.py
index fe377ed..78f2c6f 100644
--- a/arrayfire/signal.py
+++ b/arrayfire/signal.py
@@ -1264,3 +1264,15 @@ def iir(B, A, X):
Y = Array()
safe_call(backend.get().af_iir(ct.pointer(Y.arr), B.arr, A.arr, X.arr))
return Y
+
+def set_fft_plan_cache_size(cache_size):
+ """
+ Sets plan cache size.
+
+ Parameters
+ ----------
+
+ cache_size : scalar
+ the number of plans that shall be cached
+ """
+ safe_call(backend.get().af_set_fft_plan_cache_size(ct.c_size_t(cache_size)))
--
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