Do more. Code less. Free software for GPU computing.

For installation instructions, please go here.

 
Classes
       

 
class array
    array(indata = None)
 
Parameters:
----------
indata: Supports {numpy.ndarray, arrayfire.array, None}, Default: None
Input data object to be cast into arrayfire array.
 
Usage:
-------
import numpy as np
import arrayfire as af
a = np.random.rand(5, 5)
b = af.array(a)
 
  Methods defined here:
H(...)
Conjugate Transpose (Hermitian) of the matrix
 
Usage:
-----
a = af.randn(5, 3, complex64)
b = a.H()
T(...)
Transpose of the matrix
 
Usage:
-----
a = af.randu(5, 3)
b = a.T()
__add__(...)
x.__add__(y) <==> x+y
__and__(...)
x.__and__(y) <==> x&y
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(y) <==> x*y
__ne__(...)
x.__ne__(y) <==> x!=y
__neg__(...)
x.__neg__() <==> -x
__or__(...)
x.__or__(y) <==> x|y
__pos__(...)
x.__pos__() <==> +x
__radd__(...)
x.__radd__(y) <==> y+x
__rand__(...)
x.__rand__(y) <==> y&x
__repr__(...)
x.__repr__() <==> repr(x)
__rmul__(...)
x.__rmul__(y) <==> y*x
__ror__(...)
x.__ror__(y) <==> y|x
__rsub__(...)
x.__rsub__(y) <==> y-x
__rtruediv__(...)
x.__rtruediv__(y) <==> y/x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__str__(...)
x.__str__() <==> str(x)
__sub__(...)
x.__sub__(y) <==> x-y
__truediv__(...)
x.__truediv__(y) <==> x/y
host(...)
Copy data from device (arrayfire.array) to host (numpy.ndarray)
 
Returns:
-------
numpy.ndarray
 
Usage:
------
import arrayfire as af
a = af.randu(5, 5)
b = a.host() # b is now an ndarray
newdims(...)
Provide new dimensions for the array
 
Parameters:
----------
x: Supports {int, long}
Number of rows
 
y: Supports {int, long}, Default: 1
Number of columns
 
Usage:
------
a = af.randu(1, 5)
b = a.newdims(5, 1)
update(...)
For internal use only. Will be depracated in future releases.

Data descriptors defined here:
dtype
shape

Data and other attributes defined here:
__hash__ = None
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Functions
       
RTE(...)
abs(...)
acos(...)
acosh(...)
allfalse(...)
Check if all the elements in the array along the given dimension are zero
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.allfalse(a, 1)
alltrue(...)
Check if all the elements in the array along the given dimension are non zero
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.alltrue(a, 1)
areas(...)
Get areas of regions in an image
 
Parameters:
-----------
image: Supports {Arrayfire array}
The input image. This is the output of regions function.
 
Usage:
------
 
img = scipy.misc.imread(img_name)
I = af.array(img)
R = af.regions(I)
A = af.areas(R)
arrows(...)
Plot of velocity fields
 
Parameters:
----------
x: Supports {array}
Locations along x axis
 
y: Supports {array}
Locations along y axis
 
u: Supports {array}
Velocities along x axis
 
v: Supports {array}
Velocities along y axis
asin(...)
asinh(...)
atan(...)
atanh(...)
avg(...)
Average of elements in the array along the given dimension
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.avg(a, 1)
ceil(...)
centroids(...)
Get centroids of regions in an image
 
Parameters:
-----------
image: Supports {Arrayfire array}
The input image. This is the output of regions function.
 
Usage:
------
 
img = scipy.misc.imread(img_name)
I = af.array(img)
R = af.regions(I)
A = af.centroids(R)
cholesky(...)
Cholesky decomposition of input
 
Usage:
------
A = af.randu(5, 5)
P = A + A.T() + af.identity(5) * 10.0 # Generate positive definite
C = af.cholesky(P)
complex(...)
conj(...)
convolve(...)
Signal / Image Convolution
 
Parameters:
-----------
signal: Supports {Arrayfire array}
The input signal
 
kernel: Supports {Arrayfire array}
The kernel for convolution
 
mode: Supports {str}, Default: full
Convolution mode. Options: {full, same, valid}
 
Usage:
------
img = scipy.misc.imread(image_name)
tmp = scipy.misc.imread(template_name)
signal = af.array(img)
kernel = af.array(tmp)
result = af.convolve(signal, kernel)
convolve2(...)
Seperable Convolution
 
Parameters:
-----------
x: Supports {Arrayfire array}
The horizontal kernel 
 
y: Supports {Arrayfire array}
The vertical kernel 
 
signal: Supports {Arrayfire array}
The input signal
 
mode: Supports {str}, Default: full
Convolution mode. Options: {full, same, valid}
 
Usage:
------
img = scipy.misc.imread(image_name)
tmp = scipy.misc.imread(template_name)
signal = af.array(img)
kernel = af.array(tmp)
result = af.convolve(signal, kernel)
cos(...)
cosh(...)
current(...)
Get the current device number
 
Usage:
------
curr_device = af.current()
devices(...)
Get the number of devices
 
Usage:
------
num_devices = af.devices()
diagonal(...)
Extract the diagonal of a matrix
 
Usage:
------
a = af.randu(5,5)
b = diagonal(a)
diff1(...)
First order differentiation
 
Parameters:
-----------
data: Supports {array}
The input arrayfire array
 
dim: Supports {int, long}, Default: 0
The dimension along which the differentiation is perfomed
 
Usage:
------
 
a = af.randu(5,5)
b = diff1(a, 0)
c = diff1(a, 1)
diff2(...)
Second order differentiation
 
Parameters:
-----------
data: Supports {array}
The input arrayfire array
 
dim: Supports {int, long}, Default: -1
The dimension along which the differentiation is perfomed
 
Usage:
------
 
a = af.randu(5,5)
b = diff2(a, 0)
c = diff2(a, 1)
dilate(...)
Image dilation
 
Parameters:
-----------
image: Supports {Arrayfire array}
The image to be dilated
 
kernel: Supports {Arrayfire array}
The kernel for dilating
 
Usage:
------
img = af.randu(1024, 1024)
ker = af.ones(3, 3)
res = af.dilate(img, ker)
eigen(...)
Eigen value decomposition of input
 
Usage:
------
A = af.randu(5,5)
eigvals = af.eigen(A)
erf(...)
erode(...)
Image erosion
 
Parameters:
-----------
image: Supports {Arrayfire array}
The image to be eroded
 
kernel: Supports {Arrayfire array}
The kernel for eroding
 
Usage:
------
img = af.randu(1024, 1024)
ker = af.ones(3, 3)
res = af.erode(img, ker)
eval(...)
Force evaluation (Do not wait for lazy evaluation)
 
Usage:
------
x = af.randu(100000,1) 
y = af.randu(100000,1)
af.tic()
z = af.sin(af.mul(x, x)) + af.cos(af.mul(y,y))
# Use eval and sync while benchmarking only
af.eval(z) # Force evaluation
af.sync()  # Wait for syncronization
elapsed = af.toc() #
exp(...)
fft(...)
Fast fourier transform (1D)
 
Parameters:
-----------
signal: Supports {Arrayfire array}
The input signal
 
n: Supports {int, long}, Default: 0
Size of output signal. (0 meaning, dont change)
 
Usage:
------
a = af.randu(1000, 1)
b = af.fft(a)
c = af.fft(a, 1024)   # Pad input to size 1024
fft2(...)
Fast fourier transform (1D)
 
Parameters:
-----------
signal: Supports {Arrayfire array}
The input signal
 
m: Supports {int, long}, Default: 0
Rows in output signal. (0 meaning, dont change)
 
n: Supports {int, long}, Default: 0
Columns in output signal. (0 meaning, dont change)
 
Usage:
------
a = af.randu(500, 500)
b = af.fft2(a)
c = af.fft2(a, 512, 512)   # Pad input to size 512x512
filter(...)
Image filtering
 
Parameters:
-----------
image: Supports {Arrayfire array}
The image to be filtered
 
kernel: Supports {Arrayfire array}
The kernel for filtering
 
Usage:
------
img = af.randu(1024, 1024)
k = np.array([1. 0. -1.])
ker = af.array(k)
res = af.filter(img, ker)
fir(...)
Finite impulse response filter
 
Parameters:
-----------
kernel: Supports {Arrayfire array}
The kernel for filtering
 
signal: Supports {Arrayfire array}
The input signal
 
Usage:
------
ker = af.randu(100, 1)
sig = af.randu(10000, 1)
res = af.fir(ker, sig)
flat(...)
Flatten the input array
fliph(...)
Flip a matrix vertically
 
Usage:
------
a = af.randu(5,5)
b = flipv(a)
flipv(...)
Flip a matrix horizontally
 
Usage:
------
a = af.randu(5,5)
b = fliph(a)
floor(...)
grid(...)
Generate a grid from x and y values
 
Parameters:
-----------
xvals: Supports {array}
The range of the first dimension
 
yvals: Supports {array}
The range of the second dimension
 
Usage:
------
xvals = af.range(10)
yvals = af.range(10, 20)
X,Y = grid(xvals, yvals)
hessenberg(...)
Hessenberg factorization of input
 
Usage:
------
A = af.randu(5,5)
H = af.hessenberg(A)
histogram(...)
Image histogram
 
Parameters:
-----------
image: Supports {Arrayfire array}
The input image
 
bins: Supports {int, long}, Default: 32
The desired number of bins
 
mn: Supports {float, double}, Default: None
The lower limit for bin centroids (uses min(image) if None)
 
mx: Supports {float, double}, Default: None
The upper limit for bin centroids (uses max(image) if None)
 
Usage:
------
img = af.randu(1024, 1024)
res = af.histogram(img)        # Histogram of 32 bins
res = af.histogram(img, 100)   # Histogram of 100 bins
res = af.histogram(img, 100, 0.0, 255.0)
identity(...)
Generate an identity matrix
 
Prameters:
---------
x: Supports {int, long}, Default: 1
Number of rows for output array
 
y: Supports {int, long}, Default: 1
NUmber of columns for output array
 
dtype: Supports {str}, Default: float32
Datatype of output array
 
Usage:
-----
a = af.identity(x,y)
ifft(...)
Inverse fast fourier transform (1D)
 
Parameters:
-----------
signal: Supports {Arrayfire array}
The input signal
 
n: Supports {int, long}, Default: 0
Size of output signal. (0 meaning, dont change)
 
Usage:
------
a = af.randu(1000, 1)
b = af.ifft(a)
c = af.ifft(a, 1024)   # Pad input to size 1024
ifft2(...)
Inverse, fast fourier transform (1D)
 
Parameters:
-----------
signal: Supports {Arrayfire array}
The input signal
 
m: Supports {int, long}, Default: 0
Rows in output signal. (0 meaning, dont change)
 
n: Supports {int, long}, Default: 0
Columns in output signal. (0 meaning, dont change)
 
Usage:
------
a = af.randu(500, 500)
b = af.ifft2(a)
c = af.ifft2(a, 512, 512)   # Pad input to size 512x512
iir(...)
Infinite impulse response filter
 
Parameters:
-----------
feedback: Supports {Arrayfire array}
Feedback kernel
 
feedfwd: Supports {Arrayfire array}
Feedforward kernel
 
signal: Supports {Arrayfire array}
The input signal
 
Usage:
------
bak = af.randu(100, 1)
fwd = af.randu(100, 1)
sig = af.randu(10000, 1)
res = af.iir(bak, fwd, sig)
imag(...)
imgplot(...)
Display a Grayscale image
 
Usage:
------
img = scipy.misc.imread(image_name)
imgarr = af.array(img)
imgplot(imgarr)
info(...)
Display device and install information
 
Usage:
------
af.info()
inv(...)
Inverting a square matrix
 
Usage:
-----
A = af.randu(5, 5)
IA = af.inv(A)
log(...)
lower(...)
Extract the lower triangle of a matrix
 
Usage:
------
a = af.randu(5,5)
b = lower(a)
lu(...)
LU factorization of input
 
Usage:
------
A = af.randu(5,5)
LU = af.lu(A)
max(...)
Maximum of elements in the array along the given dimension
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.max(a, 1)
medfilt(...)
Median filter of an image
 
Parameters:
-----------
image: Supports {Arrayfire array}
The input image
 
m: Supports {int, long}, Default: 3
The filter height
 
n: Supports {int, long}, Default: 3
The filter width
 
Usage:
------
 
img = scipy.misc.imread(img_name)
I = af.array(img)
Res_33 = af.medfilt(I)          # 3x3 median filter
Res_55 = af.medfilt(I, 5, 5)    # 5x5 median filter
median(...)
Median of elements in the array along the given dimension
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.median(a, 1)
min(...)
Minimum of elements in the array along the given dimension
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.min(a, 1)
mpow(...)
matrix power of input
 
Usage:
------
A = af.randu(5, 5)
e = 2.0
F = mpow(A, e)
mul(...)
Element wise multiplication of two objects
 
Parameters:
-----------
left: Supports {array}
An arrayfire array class object
 
right: Supprts {array, int, float, long, double)
An arrayfire array or a regular scalar
 
Usage:
-----
a = af.randu(5, 5)
b = af.randu(5, 5)
c = mul(a, b)    # multiply two arrays
d = mul(c, 0.35) # multiply an array and a scalar
ones(...)
Generate an array of all ones
 
Prameters:
---------
x: Supports {int, long}, Default: 1
Number of rows for output array
 
y: Supports {int, long}, Default: 1
NUmber of columns for output array
 
dtype: Supports {str}, Default: float32
Datatype of output array
 
Usage:
-----
a = af.ones(x,y)
pinv(...)
Pseudoinverse of a rectangular input
 
Usage:
------
A = af.randu(5, 3)
P = af.pinv(A)
plot(...)
Line plot of the input data
 
Usage:
------
data = af.randu(5, 5)
plot(data)
plot3d(...)
Surface plot of input data
 
Usage:
------
data = af.randu(5, 5)
plot3d(data)
points(...)
3D Scatter plot
 
Parameters:
----------
x: Supports {array}
Locations along x axis
 
y: Supports {array}
Locations along y axis
 
y: Supports {array}
Locations along z axis
 
Usage:
------
x = af.randu(5,1)
y = af.randu(5,1)
z = af.randu(5,1)
points(x, y, z)
pow(...)
prod(...)
Product of elements in the array along the given dimension
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.prod(a, 1)
qr(...)
QR decomposition of input
 
Usage:
------
A = af.randu(5,5)
QR = af.lu(A)
randn(...)
Generate an array from  normal random distribution
 
Prameters:
---------
x: Supports {int, long}, Default: 1
Number of rows for output array
 
y: Supports {int, long}, Default: 1
NUmber of columns for output array
 
dtype: Supports {str}, Default: float32
Datatype of output array
 
Usage:
-----
a = af.randn(x,y)
randu(...)
Generate an array from  uniform random distribution
 
Prameters:
---------
x: Supports {int, long}, Default: 1
Number of rows for output array
 
y: Supports {int, long}, Default: 1
NUmber of columns for output array
 
dtype: Supports {str}, Default: float32
Datatype of output array
 
Usage:
-----
a = af.randu(x,y)
range(...)
Generates a range of values
 
Usage:
------
a = af.range(10)     # Generate numbers between 0  (inclusive) and 10 (exclusive)   
b = af.range(10, 20) # Generate numbers between 10 (inclusive) and 20 (exclusive)
c = af.range(100, 1000, 200) # Generate the numbers between 100 and 1000 in steps of 200
rank(...)
Rank of the input matrix
 
Usage:
------
a = af.randu(5, 3)
b = af.rank(af)
real(...)
regions(...)
Get regions in an image
 
Parameters:
-----------
image: Supports {Arrayfire array}
The input image
 
conn: Supports {int}, Default: 4
Neighborhood connectivity. Has to be 4 or 8.
 
Usage:
------
 
img = scipy.misc.imread(img_name)
I = af.array(img)
R1 = af.regions(I)
R2 = af.regions(I, 8)
resize(...)
Image resizing
 
Parameters:
-----------
image: Supports {Arrayfire array}
The image to be resized
 
scale: Supports {float, double}
The scale factor
 
Usage:
------
img = af.randu(1024, 1024)
scale = 0.5
res = af.resize(img, scale)
rotate(...)
Image rotation
 
Parameters:
-----------
image: Supports {Arrayfire array}
The image to be rotated
 
angle: Supports {float, double}
The angle of rotation (in radians)
 
Usage:
------
img = af.randu(1024, 1024)
angle = 45 * PI / 180
res = af.rotate(img, angle)
round(...)
select(...)
Select a specified device
 
Usage:
------
af.select(curr_device + 1)
shift(...)
Shift the rows and columns of input array
 
Parameters:
-----------
data: Supports {array}
The input arrayfire array
 
m: Supports {int, long}
Shifts along the first dimension
 
n: Supports {int, long}, Default: 1
Shifts along the second dimension
 
Usage:
------
 
a = af.randu(5,5)
b = shift(a, 3)
c = shift(a, 4, 4)
sin(...)
sinh(...)
solve(...)
Solve a system of equations AX=B
 
Parameters:
----------
A: Supports{array}
State matrix for the set of equations
 
B: Supports{array}
Observed results for the set of equations
 
Usage:
------
A = af.randu(5,5)
X0 = af.randu(5,1)
B = A * X0
X = solve(A, B)
af.max(af.abs(X - X0)) # Displays error
sort(...)
Sort the input array
 
Parameters:
-----------
data: Supports {array}
The input arrayfire array
 
dim: Supports {int, long}, Default: -1
The dimension along which array needs to be sorted
 
desc: Supports {bool, int, long}, Default: False
True (non zero) if sort needs to be in descending order
 
Usage:
------
 
a = af.randu(5,5)
b = sort(a)          # Ascending sort along first non-singleton
c = sort(a, 1)       # Ascending sort along the rows
d = sort(a, 0, True) # Descending sort along the columns
sqrt(...)
sum(...)
Sum of elements in the array along the given dimension
 
Parameters:
-----------
a: Supports {array}
The input array
 
dim: Supports {int, long}, Default: -1
The dimension along which the reduction takes place
 
Usage:
------
a = af.randu(5, 3)
b = af.sum(a, 1)
svd(...)
Singular value decomposition of input
 
Usage:
------
A = af.randu(5, 5)
S = svd(A)
sync(...)
Force evaluation (Do not wait for lazy evaluation)
 
Usage:
------
x = af.randu(100000,1) 
y = af.randu(100000,1)
af.tic()
z = af.sin(af.mul(x, x)) + af.cos(af.mul(y,y))
# Use eval and sync while benchmarking only
af.eval(z) # Force evaluation
af.sync()  # Wait for syncronization
elapsed = af.toc() #
tan(...)
tanh(...)
tic(...)
Starts a timer
 
Returns:
--------
A handle of the timer
 
Usage:
------
a = af.tic()
tile(...)
Create tiles of the input data
 
Parameters:
-----------
data: Supports {array}
The input arrayfire array
 
m: Supports {int, long}
Tiles along the first dimension
 
n: Supports {int, long}, Default: 1
Tiles along the second dimension
 
Usage:
------
 
a = af.randu(5,5)
b = tile(a, 3)     # b is now 15 x  5
c = tile(a, 4, 4)  # C is now 20 x 20
toc(...)
Stop a timer, return elapsed time
 
Parameters: 
-----------
val: Supports {long}, Default: None
val should be handle returned by af.tic()
 
Returns:
--------
Elapsed time
 
Usage:
------
a = af.randu(1024, 1024)
b = af.randu(32, 32)
af.tic()
c = af.convolve(a, b)
elapsed = af.toc()
upper(...)
Extract the upper triangle of a matrix
 
Usage:
------
a = af.randu(5,5)
b = upper(a)
zeros(...)
Generate an array of all zeros
 
Prameters:
---------
x: Supports {int, long}, Default: 1
Number of rows for output array
 
y: Supports {int, long}, Default: 1
NUmber of columns for output array
 
dtype: Supports {str}, Default: float32
Datatype of output array
 
Usage:
-----
a = af.zeros(x,y)