af Namespace Reference

Data Structures

class  array
 GPU array container. More...
 
class  dim4
 array dimensions descriptor More...
 
class  exception
 
class  seq
 sequential index generator More...
 
struct  timer
 

Typedefs

typedef struct af::timer timer
 

Enumerations

enum  dtype {
  f32, c32, f64, c64,
  b8, s32, u32
}
 
enum  af_source_t { afDevice, afHost }
 Specify which address-space pointer belongs. More...
 
enum  af_op_t { sum_t = 0, prod_t }
 
enum  af_solve_t {
  af_solve_none = 0, af_solve_posdef = 1, af_solve_nonposdef = 2, af_solve_gaussian = 3,
  af_solve_pseudo = 4, af_solve_ctrans = 256, af_solve_trans = 512, af_solve_uppertri = 1024,
  af_solve_lowertri = 2048, af_solve_tridiag = 4096, af_solve_blkdiag = 8192
}
 
enum  af_sparse_t { af_csr, af_csc, af_coo }
 Specify which sparse storage type. More...
 

Functions

array lu (const array &in)
 LU factorization (packed). More...
 
void lu (array &lower, array &upper, const array &in)
 LU factorization. More...
 
void lu (array &lower, array &upper, array &pivot, const array &in)
 LU factorization (with pivoting). More...
 
array qr (const array &in)
 QR factorization (packed). More...
 
void qr (array &q, array &r, const array &in)
 QR factorization. More...
 
void qr (array &q, array &r, array &tau, const array &in)
 QR factorization with tau. More...
 
array cholesky (const array &X, bool is_upper=true)
 Cholesky decomposition ("Y^T * Y == X"). More...
 
array cholesky (unsigned &info, const array &X, bool is_upper=true)
 Cholesky decomposition ("Y^T * Y == X"). More...
 
array hessenberg (const array &in)
 Hessenberg matrix form. More...
 
void hessenberg (array &h, array &q, const array &in)
 Hessenberg matrix h with unitary permutation matrix q. More...
 
array eigen (const array &in, bool is_diag=false)
 Compute eigenvalues. More...
 
void eigen (array &values, array &vectors, const array &in)
 Eigenvalues and eigenvectors. More...
 
array svd (const array &in, bool is_diag=false)
 Singular values. More...
 
void svd (array &s, array &u, array &v, const array &in)
 Singular values with unitary bases: in = u * s * v. More...
 
array inverse (const array &in)
 Matrix inversion. More...
 
array matpow (const array &base, double exponent)
 Matrix power. More...
 
unsigned rank (const array &in, double tolerance=1e-5)
 Rank of matrix. More...
 
template<typename T >
det (const array &in)
 Matrix determinant. More...
 
array solve (const array &A, const array &b, af_solve_t options=af_solve_none)
 Solve linear system. More...
 
bool gfor_toggle ()
 
handle trimesh (const float *d_X, const float *d_Y, const float *d_Z, const float *d_C, const unsigned npts)
 
AFAPI array getrow (int nrows, int *rows_idx, array sp)
 
AFAPI array getcol (int ncols, int *cols_idx, array sp)
 
void _top (const char *exp, array X)
 
void _stats (const char *exp_str, const array &exp)
 
Generate column vector
array constant (float, unsigned nx, dtype ty=f32)
 
array identity (unsigned nx, dtype ty=f32)
 
array randu (unsigned nx, dtype ty=f32)
 
array randn (unsigned nx, dtype ty=f32)
 
array rand (unsigned nx, dtype ty=u32)
 
Generate matrix
array constant (float, unsigned nx, unsigned ny, dtype ty=f32)
 
array identity (unsigned nx, unsigned ny, dtype ty=f32)
 
array randu (unsigned nx, unsigned ny, dtype ty=f32)
 
array randn (unsigned nx, unsigned ny, dtype ty=f32)
 
array rand (unsigned nx, unsigned ny, dtype ty=u32)
 
Generate volume
array constant (float, unsigned nx, unsigned ny, unsigned nz, dtype ty=f32)
 
array identity (unsigned nx, unsigned ny, unsigned nz, dtype ty=f32)
 
array randu (unsigned nx, unsigned ny, unsigned nz, dtype ty=f32)
 
array randn (unsigned nx, unsigned ny, unsigned nz, dtype ty=f32)
 
array rand (unsigned nx, unsigned ny, unsigned nz, dtype ty=u32)
 
Generate 4D array
array constant (float, unsigned d0, unsigned d1, unsigned d2, unsigned d3, dtype ty=f32)
 
array identity (unsigned d0, unsigned d1, unsigned d2, unsigned d3, dtype ty=f32)
 
array randu (unsigned d0, unsigned d1, unsigned d2, unsigned d3, dtype ty=f32)
 
array randn (unsigned d0, unsigned d1, unsigned d2, unsigned d3, dtype ty=f32)
 
array rand (unsigned d0, unsigned d1, unsigned d2, unsigned d3, dtype ty=u32)
 
Generate array
array constant (float, const dim4 &dims, dtype ty=f32)
 
array identity (const dim4 &dims, dtype ty=f32)
 
array randu (const dim4 &dims, dtype ty=f32)
 
array randn (const dim4 &dims, dtype ty=f32)
 
array rand (const dim4 &dims, dtype ty=u32)
 
array sin (const array &x)
 
array sinh (const array &x)
 
array asin (const array &x)
 
array asinh (const array &x)
 
array cos (const array &x)
 
array cosh (const array &x)
 
array acos (const array &x)
 
array acosh (const array &x)
 
array tan (const array &x)
 
array tanh (const array &x)
 
array atan (const array &x)
 
array atanh (const array &x)
 
array isFinite (const array &x)
 
array isInf (const array &x)
 
array isNaN (const array &x)
 
array sign (const array &x)
 
array sqrt (const array &x, bool isreal=false)
 Assume output will be real if isreal==true (faster), otherwise produce complex values if necessary (slower to check) More...
 
array root (const array &radicand, const array &n)
 Calculate n - th root of real - valued radicand. More...
 
array root (const array &radicand, const double n)
 Calculate n - th root of real - valued radicand. More...
 
array root (const double radicand, const array &n)
 Calculate n - th root of real - valued radicand. More...
 
array pow2 (const array &x)
 
array pow (const array &base, const array &power, bool isreal=false)
 base raised to power(exponent). More...
 
array pow (const array &base, const double power, bool isreal=false)
 base raised to power(exponent). More...
 
array pow (const double base, const array &power, bool isreal=false)
 base raised to power(exponent). More...
 
array ceil (const array &x)
 
array floor (const array &x)
 
array round (const array &x)
 
array trunc (const array &x)
 
array factorial (const array &x)
 
array min (const array &x, const array &y)
 Minimum between x and y at every position. More...
 
array min (const double x, const array &y)
 Minimum between x and every element of y. More...
 
array max (const array &x, const array &y)
 Maximum between x and y at every position. More...
 
array max (const double x, const array &y)
 Maximum between x and every element of y. More...
 
array log (const array &x, bool isreal=false)
 Assume output will be real if isreal==true (faster), otherwise produce complex values if necessary (slower to check) More...
 
array log2 (const array &x)
 
array log10 (const array &x)
 
array log1p (const array &x)
 
array exp (const array &x)
 
array expm1 (const array &x)
 
array gamma (const array &x)
 
array gammaln (const array &x)
 
array epsilon (const array &x)
 
array erf (const array &x)
 
array erfc (const array &x)
 
array erfinv (const array &x)
 
array erfcinv (const array &x)
 
array abs (const array &x)
 
array arg (const array &x)
 
array conjg (const array &x)
 
array real (const array &x)
 
array imag (const array &x)
 
array complex (const array &x)
 
array complex (const array &real, const array &imaginary)
 Form a complex result from one real input. More...
 
array complex (const array &real, const double imaginary)
 Form a complex result from real and imaginary parts. More...
 
array complex (const double real, const array &imaginary)
 Form a complex result from real and imaginary parts. More...
 
array atan2 (const array &, const array &)
 arc tangent function of two variables More...
 
array atan2 (const array &, const double)
 arc tangent function of two variables More...
 
array atan2 (const double, const array &)
 arc tangent function of two variables More...
 
array hypot (const array &, const array &)
 Euclidean distance function without undue overflow or underflow during intermediate steps. More...
 
array hypot (const array &, const double)
 Euclidean distance function without undue overflow or underflow during intermediate steps. More...
 
array hypot (const double, const array &)
 Euclidean distance function without undue overflow or underflow during intermediate steps. More...
 
array rem (const array &, const array &)
 remainder More...
 
array rem (const array &, const double)
 remainder More...
 
array rem (const double, const array &)
 remainder More...
 
array mod (const array &x, const array &y)
 Compute x - n * y where n is quotient of x / y. More...
 
array mod (const array &x, const double y)
 Compute x - n * y where n is quotient of x / y. More...
 
array mod (const double x, const array &y)
 Compute x - n * y where n is quotient of x / y. More...
 
array lower (const array &input, int diagonal=0)
 Extract lower triangular matrix. More...
 
array upper (const array &input, int diagonal=0)
 Extract upper triangular matrix. More...
 
array diag (const array &input)
 Extract or form diagonal matrix. More...
 
array join (int dim, const array &A, const array &B)
 Join two arrays along dimension dim. More...
 
array join (int dim, const array &A, const array &B, const array &C)
 
array join (int dim, const array &A, const array &B, const array &C, const array &D)
 
array flip (const array &in, unsigned dim)
 Flip array along a given dimension (base-zero index). More...
 
void sync ()
 
array eval (array a)
 Evaluate an expression (nonblocking). More...
 
void eval (array a, array b)
 
void eval (array a, array b, array c)
 
void eval (array a, array b, array c, array d)
 
void eval (array a, array b, array c, array d, array e)
 
void eval (array a, array b, array c, array d, array e, array f)
 
template<typename ty >
ty norm (const array &in, float p=af::NaN)
 Matrix or vector norm. More...
 
template<typename ty >
ty dot (const array &x, const array &y)
 Scalar dot product between two vectors. More...
 
array matmul (const array &, const array &, af_matprop_t=af_none, af_matprop_t=af_none)
 Multiply two arrays together. More...
 
array matmul (const array &, const array &, const array &)
 Multiply three arrays together. More...
 
array matmul (const array &, const array &, const array &, const array &)
 Multiply four arrays together. More...
 
void info (bool isdebug=false)
 Print diagnostic information on driver, runtime, memory, and devices. More...
 
void deviceprop (char *d_name, char *d_platform, char *d_toolkit, char *d_compute)
 Returns information about current device and platform. More...
 
void deviceset (int index)
 Switch to specified device. More...
 
int deviceget ()
 Return the index of current device. More...
 
int devicecount ()
 Returns the number of available devices. More...
 
array sum (const array &input, int dim=-1)
 
template<typename ty >
ty sum (const array &input)
 
array mul (const array &input, int dim=-1)
 
template<typename ty >
ty mul (const array &input)
 
array min (const array &input, int dim=-1)
 Minimum of the elements along a dimension in matrix. More...
 
void min (array &values, array &indices, const array &input, int dim=-1)
 Minimum value and index found along dimension. More...
 
template<typename ty >
ty min (const array &input)
 Minimum value among all elements in array. More...
 
template<typename ty >
void min (ty *value, int *index, const array &input)
 Minimum value and index among all elements in array. More...
 
array max (const array &input, int dim=-1)
 Maximum of the elements along a dimension in matrix. More...
 
void max (array &values, array &indices, const array &input, int dim=-1)
 Maximum value and index found along dimension. More...
 
template<typename ty >
ty max (const array &input)
 Maximum value among all elements in array. More...
 
template<typename ty >
void max (ty *value, int *index, const array &input)
 Maximum value and index among all elements in array. More...
 
array minmax_packed (const array &input, int dim=-1)
 Minimum and maximum (packed) of the elements along a dimension in matrix. More...
 
void minmax (array &minvalues, array &maxvalues, const array &input, int dim=-1)
 Minimum and maximum of the elements along a dimension in matrix. More...
 
template<typename ty >
ty minmax (const array &input)
 Minimum (out.x) and maximum (out.y) values among all elements in array. More...
 
array alltrue (const array &input, int dim=-1)
 Test if all elements are true (nonzero) along a dimension in input. More...
 
template<typename ty >
ty alltrue (const array &input)
 Test if all elements are true (nonzero) in entire array. More...
 
array anytrue (const array &input, int dim=-1)
 Test if all elements are false (zero) along a dimension in input. More...
 
template<typename ty >
ty anytrue (const array &input)
 Test if all elements are false (zero) in entire array. More...
 
array where (const array &input)
 Indices where nonzero (zero-based indexing). More...
 
void where (array &row, array &column, const array &input)
 row and column indices of nonzero elements in input More...
 
unsigned count (const array &input)
 Count nonzero elements in input. More...
 
array segsum (const array &input, const array &segments, bool reduce=false)
 
array accum (const array &input, int dim=-1, af_op_t op=sum_t, bool isupcast=false)
 accumulated sum More...
 
array setunique (const array &input)
 Unique values. More...
 
void setunique (array &values, array &indices, array &locations, const array &input)
 
array setunion (const array &A, const array &B)
 Union of two vectors. More...
 
void setunion (array &U, array &IA, array &IB, const array &A, const array &B)
 Union of two vectors and their indices. More...
 
array setintersect (const array &A, const array &B)
 Intersection of two vectors. More...
 
void setintersect (array &U, array &IA, array &IB, const array &A, const array &B)
 Intersection of two vectors and their indices. More...
 
array mean (const array &input, int dim=-1)
 Average along a dimension. More...
 
template<typename ty >
ty mean (const array &input)
 Average of all elements in array. More...
 
array var (const array &input, bool isbiased=false, int dim=-1)
 Variance along a dimension. More...
 
array var (const array &input, const array weights, int dim=-1)
 Weighted variance along a dimension. More...
 
template<typename ty >
ty var (const array &input, bool isbiased=false)
 Variance of all elements in array. More...
 
template<typename ty >
ty var (const array &input, const array weights)
 Weighted variance of all elements in array. More...
 
array cov (const array &input, bool isbiased=false)
 Covariance of row observations. More...
 
array cov (const array &X, const array &Y, bool isbiased=false)
 Covariance between two jointly distributed random variables. More...
 
array stdev (const array &in, int dim=-1)
 Standard deviation along a dimension. More...
 
template<typename ty >
ty stdev (const array &input)
 Standard deviation of all elements in a vector. More...
 
array median (const array &input, int dim=-1)
 Median along a dimension. More...
 
template<typename ty >
ty median (const array &input)
 Median of all elements in array. More...
 
template<typename ty >
ty corrcoef (const array &x, const array &y)
 Correlation coefficient of two inputs of same size. More...
 
array local (const array &variable)
 Indicate when a variable is unique to each iteration, i.e. More...
 
array gfor (double n)
 Do not use this function directly; see GFOR: Parallel For-Loops. More...
 
array gfor (double first, double last)
 Do not use this function directly; see GFOR: Parallel For-Loops. More...
 
array gfor (double first, double inc, double last)
 Do not use this function directly; see GFOR: Parallel For-Loops. More...
 
Matrix Interface: Surface plot of 2D data.
array a(seq(10));
a = tile(a,1,10);
//a = 10 columns, each containing numbers 0-9
Parameters
[in]X2D matrix with which to draw simple surface plot
handle surface (const af::array &X)
 
Matrix Interface: Visualize 2D velocity field with an array of arrows
array a(seq(10));
//create arrows along the diagonal
//the arrows rotate around the unit circle
arrows(a,a, cos(a), sin(a));
// using existing 2D flow matrices u,v
// ...
// create x,y map for indexing
array xx = tile(array(seq(u.dims(1))).T(),u.dims(0),1);
array yy = tile(array(seq(v.dims(0))),1,v.dims(1));
// draw 2D flow field
arrows(xx,yy,u,v);
Parameters
[in]X0,Y0coordinates of points from which to draw
[in]X1,Y1coordinates of points to which to draw
Note
this function does not work on OSX yet, due to lack of certain OpenGL shader support
handle arrows (const af::array &X0, const af::array &Y0, const af::array &X1, const af::array &Y1)
 
Matrix Interface: Visualize 1D data as a line plot
Parameters
[in]Xmatrix containing data to be visualized
[in]linestyleoptional string indicating desired characteristics of plot
Note
valid options for linestyle:
--Plot*--
  b     blue
  g     green
  r     red
  c     cyan
  m     magenta
  y     yellow
  k     black
  w     white
handle plot2 (const af::array &X)
 
handle plot2 (const af::array &X, const char *linestyle)
 
Matrix Interface: Visualize 2D data as a line plot
Parameters
[in]Xmatrix containing horizontal data to be visualized
[in]Ymatrix containing vertical data to be visualized
[in]linestyleoptional string indicating desired characteristics of plot
Note
valid options for linestyle:
--Plot*--
  b     blue
  g     green
  r     red
  c     cyan
  m     magenta
  y     yellow
  k     black
  w     white
handle plot2 (const array &X, const array &Y)
 
handle plot2 (const array &X, const array &Y, const char *linestyle)
 
Matrix Interface: Visualize 3D data as scatter plot
array a(seq(10));
array b = a + randu(10);
plot3(a,b,a);
Parameters
[in]Xmatrix containing X data to be visualized
[in]Ymatrix containing Y data to be visualized
[in]Zmatrix containing Z data to be visualized
handle plot3 (const af::array &X, const af::array &Y, const af::array &Z)
 
Matrix Interface: Visualize 3D data volume
array a( seq( 0, 0.1, 1 ) );
a = tile(a, 1, 10, 10);
//a is symmetric in the y and z dimensions and increases along the x dimension
volume(a);
Parameters
[in]X3D array to be volume rendered
handle volume (const af::array &X)
 
Matrix Interface: Visualize 2D data as single scale image

If matrix is 3D (last dimension size is 3), it is treated as a color image with red, green, blue channels.

array a(seq(10));
a = tile(a,1,10);
a += a.T();
image(a);
Parameters
[in]X2D matrix to be visualized
Note
Automatically scales palette based on min/max values
handle image (const af::array &X)
 
Device pointer interface: Surface plot of 2D data.
Parameters
[in]d_a2D device pointer to data with which to draw surfaceace plot
[in]d_wWidth of data and surfaceace plot
[in]d_hHeight of data and surfaceace plot
handle surface (const float *d_a, const unsigned w, const unsigned h)
 
Device pointer interface: Visualize 2D velocity field with an array of arrows
Parameters
[in]d_X0device pointer to X data containing horizontal base positions for arrows
[in]d_Y0device pointer to Y data containing vertical base positions for arrows
[in]d_X1device pointer to data containing horizontal velocity components
[in]d_Y1device pointer to data containing vertical velocity components
[in]cntnumber of arrows to render in velocity plot
handle arrows (const float *d_X0, const float *d_Y0, const float *d_X1, const float *d_Y1, const int cnt)
 
Device pointer interface: Visualize 1D data as a line plot
Parameters
[in]d_Adevice pointer to data to be visualized
[in]lenThe length of the data to be visualized
[in]optionalparameter specifying the visual characteristics of the line plot
handle plot2 (const float *d_A, const unsigned len)
 
handle plot2 (const float *d_A, const unsigned len, const char *linestyle)
 
Device pointer interface: Visualize 2D data with X and Y labels
Parameters
[in]d_Xdevice pointer to X data to be visualized
[in]d_Ydevice pointer to Y data to be visualized
[in]nptsThe length of the data to be visualized
handle plot2 (const float *d_X, const float *d_Y, const unsigned npts)
 
Device pointer interface: Visualize 2D data with X and Y labels, linestyle
Parameters
[in]d_Xdevice pointer to X data to be visualized
[in]d_Ydevice pointer to Y data to be visualized
[in]nptsThe length of the data to be visualized
[in]linestyleOptional parameter determining the visual characteristics of the line plot
handle plot2 (const float *d_X, const float *d_Y, const unsigned npts, const char *linestyle)
 
Device pointer interface: Visualize 3D data as a line plot
Parameters
[in]d_Xdevice pointer to X data to be visualized
[in]d_Ydevice pointer to Y data to be visualized
[in]d_Zdevice pointer to Z data to be visualized
[in]nptsThe length of the data to be visualized
[in]linestyleOptional parameter determining the visual characteristics of the line plot
handle plot3 (const float *d_X, const float *d_Y, const float *d_Z, const unsigned npts)
 
handle plot3 (const float *d_X, const float *d_Y, const float *d_Z, const unsigned npts, const char *linestyle)
 
Device pointer interface: Visualize 3D data as a volume rendering
Parameters
[in]d_Xdevice pointer to 3D data to be visualized
[in]wThe width of the data to be visualized
[in]hThe height of the data to be visualized
[in]dThe depth of the data to be visualized
handle volume (const float *d_X, const unsigned w, const unsigned h, const unsigned d)
 
Device pointer interface: Visualize 3D data as a colored scatter plot
Parameters
[in]d_Xdevice pointer to X component of data to be visualized
[in]d_Ydevice pointer to Y component of data to be visualized
[in]d_Zdevice pointer to Z component of data to be visualized
[in]d_Rdevice pointer to red color component data to be visualized
[in]d_Gdevice pointer to green color component data to be visualized
[in]d_Bdevice pointer to blue color component data to be visualized
[in]nptsThe number of 3D points to visualize
handle scattercolors (const float *d_X, const float *d_Y, const float *d_Z, const float *d_R, const float *d_G, const float *d_B, const unsigned npts)
 
Device pointer interface: Visualize 2D data as single scale image
Parameters
[in]d_XDevice pointer to 2D matrix to be visualized
[in]wwidth of 2D matrix to be visualized
[in]hheight of 2D matrix to be visualized
Note
see Color Palettes for available color schemes
handle image (const float *d_X, const unsigned w, const unsigned h)
 
Device pointer interface: Visualize 2D data as color image
Parameters
[in]d_XDevice pointer to 2D matrix to be visualized.
[in]wwidth of 2D matrix to be visualized
[in]hheight of 2D matrix to be visualized
handle rgbplot (const float *d_X, const unsigned w, const unsigned h)
 
Display a figure window
Note
see Usage for available commands
see Color Palettes for available color schemes
handle fig (const char *key, const char *val=NULL)
 
Create figure with tiled layout.
handle fig (const char *key, int nx, int ny, int i)
 
Display the current figure with given geometry
Parameters
[in]xThe horizontal position of the upper left corner of the figure
[in]yThe vertical position of the upper left corner of the figure
[in]wThe width of the figure
[in]hThe height of the figure
handle fig (int x, int y, int w, int h)
 
array gaussiankernel (int rows, int cols, double sigma_r=0, double sigma_c=0)
 Generate kernels. More...
 
array filter (const array &image, const array &kernel)
 Image Filtering. More...
 
array medfilt (const array &image, const unsigned height=3, const unsigned width=3)
 Median filtering within window (default 3x3) More...
 
array minfilt (const array &image, const unsigned height=3, const unsigned width=3)
 Minimum filtering within window (default 3x3) More...
 
array maxfilt (const array &image, const unsigned height=3, const unsigned width=3)
 Maximum filtering within window (default 3x3) More...
 
array rotate (const array &image, const float theta, bool iscrop=true)
 
array erode (const array &image, const array &mask)
 
array dilate (const array &image, const array &mask)
 
array resize (const float scale, const array &image, const char method='L')
 Resize an image based on a scaling factor (uniform) More...
 
array resize (const float scale_x, const float scale_y, const array &image, const char method='L')
 Resize an image based on two scale factors (non-uniform) More...
 
array resize (const unsigned height, const unsigned width, const array &image, const char method='L')
 Resize an image to a specified width and height in pixels. More...
 
array bilateral (const array &image, const float space, const float color)
 Bilateral filtering. More...
 
array meanshift (const array &image, const float space, const float color, const int iter=5)
 Meanshift filtering. More...
 
array colorspace (const array &image, const af_cspace_t to, const af_cspace_t from)
 
array histogram (const array &data, unsigned nbins)
 Histogram takes in the input array data and computes the minimum and maximum of the range. More...
 
array histogram (const array &data, unsigned nbins, float min, float max)
 This function takes in the input array data. More...
 
array histequal (const array &data, const array &histogram)
 
array regions (const array &image, const unsigned connectivity=8)
 
array areas (const array &regions)
 
array centroids (const array &regions)
 
array loadimage (const char *filename, bool iscolor=false)
 Load an image from disk. More...
 
void saveimage (const char *filename, const af::array &img)
 Save an image to disk. More...
 
array diff1 (const array &in, int dim=-1)
 
array diff2 (const array &in, int dim=-1)
 
void grad (array &dcols, array &drows, const array &in)
 
array tile (const array &A, unsigned d0, unsigned d1=1, unsigned d2=1)
 
array tile (const array &A, const dim4 &dims)
 
array flat (const array &A)
 No work is done (data is simply shared) so this is effectively a noop. More...
 
array moddims (const array &A, int dim0, int dim1=1, int dim2=1, int dim3=1)
 This function changes the dimensions of an array. More...
 
array moddims (const array &A, const dim4 &dims)
 This function changes the dimensions of an array. More...
 
array shift (const array &in, int dim0=0, int dim1=0, int dim2=0, int dim3=0)
 Shift the values of an array around dimension (wrap around). More...
 
array shift (const array &in, const array &shift)
 Shift the values of an array around dimension (wrap around). More...
 
array reorder (const array &in, int dim0=-1, int dim1=-1, int dim2=-1, int dim3=-1)
 Reorder dimensions of array. More...
 
array sort (const array &in, int dim=-1, bool isdescending=false)
 Sort array along dimension. More...
 
void sort (array &values, array &indices, const array &in, int dim=-1, bool isdescending=false)
 Sort array along dimension and return original indices of sorted values. More...
 
void sort (array &outkeys, array &outvalues, const array &keys, const array &values, bool isdescending=false)
 Sort array values based on keys along dimension. More...
 
array sortdim (const array &in, int dim=0)
 Sort treating one dimension as keys in specific order. More...
 
array sortdim (const array &in, int dim, unsigned norder, const int *h_order)
 Sort treating one dimension as keys in specific order. More...
 
array fft (const array &, int pad=-1)
 Fast Fourier Transform in one dimension. More...
 
array fft2 (const array &, int nx=-1, int ny=-1)
 Fast Fourier Transform in two dimensions. More...
 
array fft3 (const array &, const dim4 &dims=dim4(0))
 Fast Fourier Transform in three dimensions. More...
 
Inverse Fast Fourier Transform
array ifft (const array &, int pad=-1)
 Inverse Fast Fourier Transform in one dimension. More...
 
array ifft2 (const array &, int nx=-1, int ny=-1)
 Inverse Fast Fourier Transform in two dimensions. More...
 
array ifft3 (const array &, const dim4 &dims=dim4(0))
 Inverse Fast Fourier Transform in three dimensions. More...
 
array fir (int nb, const float *h_b, const array &x)
 
array fir (const array &b, const array &x)
 Finite impulse response filtering. More...
 
array iir (int nb, const float *h_b, int na, const float *h_a, const array &x)
 
array iir (const array &b, const array &a, const array &x)
 
array convolve (const array &f1, const array &f2, const array &signal, bool expand=false)
 Separable convolution (2D) with device arrays. More...
 
template<typename ty >
array convolve (unsigned n1, const ty *h_f1, unsigned n2, const ty *h_f2, const array &signal, bool expand=false)
 Separable convolution (2D) with host arrays. More...
 
array convolve (const array &signal, const array &filter, bool expand=false)
 Convolution (1D,2D,3D). More...
 
template<typename ty >
array convolve (const array &signal, unsigned ndims, unsigned *dims, const ty *h_kernel, bool expand=false)
 Convolution (1D,2D,3D) with host filter. More...
 
array approx1 (const array &Y, const array &Xi, char method='L', float offgrid=af::NaN)
 Interpolation in one dimension (1D). More...
 
array approx2 (const array &Z, const array &Xi, const array &Yi, char method='L', float offgrid=af::NaN)
 Interpolation in two dimensions (2D): z=f(x,y) More...
 
Construct CSR-format sparse matrix from pointers
Parameters
[in]row_idxRow indices in CSR format
[in]col_idxColumn indices in CSR format
[in]valuesArray containing nonzero values
[in]nrowsNumber of rows in the matrix
[in]ncolsNumber of columns in the Matrix
[in]nonzeroNumber of non zero elements
[in]srcSpecify if pointers are from Host (default) or device
[in]ngforThe gfor tile size (default 0)
Returns
sparse nrows-by-ncols array in af_csr format
AFAPI array sparse (const int *row_idx, const int *col_idx, const float *values, int nrows, int ncols, int nonzero, af_source_t src=afHost, unsigned ngfor=0)
 
AFAPI array sparse (const int *row_idx, const int *col_idx, const double *values, int nrows, int ncols, int nonzero, af_source_t src=afHost, unsigned ngfor=0)
 
AFAPI array sparse (const int *row_idx, const int *col_idx, const cfloat *values, int nrows, int ncols, int nonzero, af_source_t src=afHost, unsigned ngfor=0)
 
AFAPI array sparse (const int *row_idx, const int *col_idx, const cdouble *values, int nrows, int ncols, int nonzero, af_source_t src=afHost, unsigned ngfor=0)
 
Construct sparse matrix from Dense
Parameters
[in]denseMatrix stored as dense
Returns
out A sparse matrix stored in CSR format
AFAPI array sparse (array dense)
 
Construct sparse matrix from arrays
Parameters
[in]row_idxrow indices
[in]col_idxcolumn indices
[in]valuesnonzero values
[in]nrowsNumber of rows (default -1 uses max(row_idx) for COO, row_idx.elements()-1 for CSR)
[in]ncolsNumber of columns (default -1 uses max(J))
[in]formatsparse format (default: af_coo)
Returns
sparse nrows-by-ncols array
AFAPI array sparse (array &row_idx, array &col_idx, array &values, int nrows=-1, int ncols=-1, af_sparse_t format=af_coo)
 
Create dense matrix from sparse matrix
Parameters
[in]sparseSparse matrix generated by ArrayFire
Returns
dense matrix
AFAPI array dense (array sparse)
 
Parameters
[in]spThe sparse matrix
[in]formatThe required output format
[out]IThe row indices
[out]JThe column indices
[out]ValThe non zero values
AFAPI afError where (array &I, array &J, array &Val, array sp, af_sparse_t format=af_coo)
 
double timeit (void(*fn)())
 
void _print (const char *str, const array exp)
 Display expression and its value. More...
 
void _printdims (const char *str, const array exp)
 Display expression and its dimensions. More...
 

Variables

const double NaN
 representation for not-a-number More...
 
const double Inf
 representation for positive infinity More...
 
const double Pi
 representation for Pi (3.1415926535897931) More...
 
const cfloat i
 representation for imaginary unit 0+1i More...
 
int end
 Reference last element in dimension. More...
 
seq span
 Reference entire dimension. More...
 

Typedef Documentation

typedef struct af::timer timer

Internal timer object

Enumeration Type Documentation

enum dtype

Tokens indicating data type

Enumerator
f32 

floating point (32-bit single-precision)

c32 

complex-valued floating point (32-bit single-precision real and imaginary components)

f64 

floating point (64-bit double-precision)

c64 

complex-valued floating point (64-bit double-precision real and imaginary components)

b8 

boolean (8-bit: nonzero=true, zero=false)

s32 

signed 32-bit integer

u32 

unsigned 32-bit integer

Specify which address-space pointer belongs.

Enumerator
afDevice 

Device-memory pointer.

afHost 

Host-memory pointer.

enum af_op_t
Enumerator
sum_t 
prod_t 

Specify which sparse storage type.

Enumerator
af_csr 

CSR format.

af_csc 

CSC format.

af_coo 

COO format.

Function Documentation

bool af::gfor_toggle ( )
handle af::trimesh ( const float *  d_X,
const float *  d_Y,
const float *  d_Z,
const float *  d_C,
const unsigned  npts 
)
AFAPI array af::getrow ( int  nrows,
int *  rows_idx,
array  sp 
)
AFAPI array af::getcol ( int  ncols,
int *  cols_idx,
array  sp 
)
void af::_top ( const char *  exp,
array  X 
)
void af::_stats ( const char *  exp_str,
const array &  exp 
)

Variable Documentation

const double NaN

representation for not-a-number

const double Inf

representation for positive infinity

const double Pi

representation for Pi (3.1415926535897931)

Examples:
examples/image_processing/image_demo.cpp, and examples/visualization/vortex.cpp.