ArrayFire Python Wrapper¶
Introduction¶
ArrayFire is a high performance scientific computing library with an easy to use API.
>>> # Monte Carlo estimation of pi
>>> def calc_pi_device(samples):
# Simple, array based API
# Generate uniformly distributed random numers
x = af.randu(samples)
y = af.randu(samples)
# Supports Just In Time Compilation
# The following line generates a single kernel
within_unit_circle = (x * x + y * y) < 1
# Intuitive function names
return 4 * af.count(within_unit_circle) / samples
Programs written using ArrayFire are portable across CUDA, OpenCL and CPU devices.
The default backend is chosen in the following order of preference based on the available libraries:
CUDA
OpenCL
CPU
The backend can be chosen at the beginning of the program by using the following function
>>> af.set_backend(name)
where name is one of ‘cuda’, ‘opencl’ or ‘cpu’.
The functionality provided by ArrayFire spans the following domains:
Vector Algorithms
Image Processing
Signal Processing
Computer Vision
Linear Algebra
Statistics
Submodules¶
Vector algorithms (sum, min, sort, etc). 

Math functions (sin, sqrt, exp, etc). 

Array class and helper functions. 

Implementation of BaseArray class. 

Function to perform broadcasting operations. 

BLAS functions (matmul, dot, etc) 

Functions specific to CUDA backend. 

Functions to create and manipulate arrays. 

Functions to handle the available devices in the backend. 

Features class used for Computer Vision algorithms. 

Graphics functions (plot, image, etc). 

Image processing functions. 

Index and Seq classes used in indexing operations. 

Interop with other python packages. 

Dense Linear Algebra functions (solve, inverse, etc). 

Module containing enums and other constants. 

Functions specific to OpenCL backend. 

Random engine class and functions to generate random numbers. 

Functions to create and manipulate sparse matrices. 

Signal processing functions (fft, convolve, etc). 

Statistical algorithms (mean, var, stdev, etc). 

Functions to time arrayfire. 

Utility functions to help with Array metadata. 

Computer vision functions (FAST, ORB, etc) 