array Class Reference

GPU array container. More...

#include <array.h>

Public Member Functions

array copy () const
 Create a deep-copy of another array for modification. More...
 
 array (ginternal *)
 
 ~array ()
 
 array ()
 Create non-dimensioned array (no data, undefined size) More...
 
 array (const dim4 &dims, dtype ty=f32)
 Allocate an array of a specified size with undefined contents. More...
 
 array (int d0, int d1, dtype ty=f32)
 Allocate a two-dimensional array of a specified size with undefined contents. More...
 
 array (int d0, int d1, int d2, dtype ty=f32)
 Allocate a three-dimensional (3D) array of a specified size with undefined contents. More...
 
 array (int d0, int d1, int d2, int d3, dtype ty=f32)
 Allocate a four-dimensional (4D) array of a specified size with undefined contents. More...
 
 array (const array &)
 Duplicate an existing array (copy constructor). More...
 
 array (const seq &s)
 Convert a seq object for use with arithmetic. More...
 
template<typename ty >
 array (unsigned dim0, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create a column vector on the device using a host/device pointer. More...
 
template<typename ty >
 array (unsigned dim0, unsigned dim1, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create a 2D array on the device using a host/device pointer. More...
 
template<typename ty >
 array (unsigned dim0, unsigned dim1, unsigned dim2, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create a 3D array on the device using a host/device pointer. More...
 
template<typename ty >
 array (unsigned dim0, unsigned dim1, unsigned dim2, unsigned dim3, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create a 4D array on the device using a host/device pointer. More...
 
template<typename ty >
 array (const dim4 &dims, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create an array of specified size on the device using a host/device pointer. More...
 
 array (const array &input, const dim4 &dims)
 Adjust the dimensions of an N-D array (fast). More...
 
 array (const array &input, int dim0, int dim1=1, int dim2=1, int dim3=1)
 Adjust the dimensions of an N-D array (fast). More...
 
dim4 dims () const
 Return a dim4 object with the dimensions of the array. More...
 
int dims (unsigned dim) const
 Return the size of the dimension specified by index dim (zero-indexed). More...
 
int numdims () const
 Returns the number of dimensions whose size is greater then one. More...
 
int elements () const
 
int nonzeros () const
 Returns the number of the nonzero elements. More...
 
unsigned ngfor () const
 Returns the number of gfor tiles. More...
 
size_t bytes () const
 Returns the memory allocated by the array. More...
 
bool isempty () const
 Checks if array contains any elements. More...
 
bool isscalar () const
 Checks if the array contains only one element. More...
 
bool isvector () const
 Checks if the array has only one dimension. More...
 
bool isrow () const
 Checks if the array has only one row. More...
 
bool iscolumn () const
 Checks if the array has only one column. More...
 
dtype type () const
 Returns the type of the array. More...
 
bool iscomplex () const
 Checks if the array is a complex type. More...
 
bool isreal () const
 
bool issparse () const
 Checks if the array is a sparse matrix. More...
 
void eval ()
 Evaluate all expressions associated with the variable. More...
 
void unlock () const
 Regain control of a device pointer after a call to device() More...
 
array row (int index) const
 Access row index to form row vector. More...
 
array col (int index) const
 Access column index to form column vector. More...
 
array slice (int index) const
 Access slice index to form a matrix (plane of a volume, channel in an image) More...
 
array rows (int first, int last) const
 Access rows first through last to form a matrix (inclusive). More...
 
array cols (int first, int last) const
 Access columns first through last to form a matrix (inclusive) More...
 
array slices (int first, int last) const
 Access slices first through last to form a matrix (inclusive) More...
 
array operator() (int index) const
 Access linear element at index. More...
 
array operator() (const seq &s) const
 Access linear sequence of elements. More...
 
array operator() (array indices) const
 Access elements specified by values in an index array. More...
 
array operator() (const seq &rows, const seq &cols) const
 Access submatrix sequence of elements. More...
 
array operator() (int row, int col) const
 Access the element at location (row, col). More...
 
array operator() (int row, const seq &y) const
 Access linear sequence of elements at location row and y seq of columns. More...
 
array operator() (int row, array columns) const
 Access linear sequence of elements at location row and columns array of indices of columns. More...
 
array operator() (const seq &x, int column) const
 Access linear sequence of elements at location row and column. More...
 
array operator() (const seq &rows, array columns) const
 Access elements along sequence row and index array column. More...
 
array operator() (array rows, int column) const
 Access elements along index array rows and location column. More...
 
array operator() (array rows, const seq &columns) const
 Access elements along index array rows and sequence of columns. More...
 
array operator() (array rows, array columns) const
 Access elements along index array rows and index array columns. More...
 
array operator() (int x, int y, int z) const
 Access elements at location row x, column y and slice z. More...
 
array operator() (const seq &x, int y, int z) const
 Access elements at sequence of rows x, column y and slice z. More...
 
array operator() (int x, const seq &y, int z) const
 Access elements at row x, sequence of columns y and slice z. More...
 
array operator() (int x, int y, const seq &z) const
 Access elements at row x, column y, and sequence of slices z. More...
 
array operator() (int x, const seq &y, const seq &z) const
 Access elements at row x, sequence of columns y, and sequence of slices z. More...
 
array operator() (const seq &x, const seq &y, int z) const
 Access elements at sequence of rows x, sequence of columns y, and slice z. More...
 
array operator() (const seq &x, int y, const seq &z) const
 Access elements at sequence of rows x, column y, and sequence of slices z. More...
 
array operator() (const seq &x, const seq &y, const seq &z) const
 Access elements at sequence of rows x, sequence of columns y, and sequence of slices z. More...
 
array operator() (array rows, array cols, const seq &slices) const
 Access elements at array of row indices rows, array of column indices cols, and sequence of slices slices. More...
 
array operator() (array rows, array cols, int slice) const
 Access elements at array of row indices rows, array of column indices cols, and slice. More...
 
array operator() (array rows, const seq &cols, const seq &slices) const
 Access elements at array of row indices rows, sequence of column indices cols, and sequence of slice indices slices. More...
 
array operator() (array rows, const seq &cols, int slice) const
 Access elements at array of row indices rows, sequence of column indices cols, and slice. More...
 
array operator() (const seq &rows, array cols, const seq &slices) const
 Access elements at sequence of row indices rows, array of column indices cols, and sequence of slice indices slices. More...
 
array operator() (const seq &rows, const seq &cols, array slices) const
 Access elements at sequence of row indices rows, sequence of column indices cols, and array of slice indices slices. More...
 
array operator() (const seq &w, const seq &x, const seq &y, const seq &z) const
 Access volume. More...
 
array operator() (const seq &w, const seq &x, const seq &y, int z) const
 Access volume. More...
 
array operator() (const seq &w, const seq &x, int y, int z) const
 Access volume. More...
 
array operator() (const int w, const seq &x, const seq &y, const seq &z) const
 Access volume. More...
 
array operator() (const seq &w, const int x, const seq &y, const seq &z) const
 Access volume. More...
 
array operator() (const seq &w, const seq &x, const int y, const seq &z) const
 Access volume. More...
 
array operator() (const int w, const int x, const int y, const int z) const
 Access volume. More...
 
template<typename T >
T scalar () const
 Returns host-side scalar of first component of data. More...
 
template<typename T >
Tdevice () const
 
template<typename T >
Thost () const
 Returns the data to device pointer of type T. More...
 
void host (void *ptr) const
 Copy device data to host-side pointer. More...
 
array operator- () const
 
array operator! () const
 
arrayoperator+= (const array &)
 
arrayoperator+= (const double &)
 
arrayoperator+= (const cfloat &)
 
arrayoperator+= (const cdouble &)
 
arrayoperator-= (const array &)
 
arrayoperator-= (const double &)
 
arrayoperator-= (const cfloat &)
 
arrayoperator-= (const cdouble &)
 
arrayoperator*= (const array &)
 
arrayoperator*= (const double &)
 
arrayoperator*= (const cfloat &)
 
arrayoperator*= (const cdouble &)
 
arrayoperator/= (const array &)
 
arrayoperator/= (const double &)
 
arrayoperator/= (const cfloat &)
 
arrayoperator/= (const cdouble &)
 
arrayoperator%= (const array &)
 
arrayoperator%= (const double &)
 
arrayoperator++ ()
 
arrayoperator-- ()
 
array operator^ (const array &) const
 
template<typename ty >
arrayoperator= (const ty value)
 Scalar assignment. More...
 
arrayoperator= (const array &a)
 Array assignment. More...
 
array T () const
 Transpose matrix or vector. More...
 
array H () const
 Conjugate transpose (1+2i becomes 1-2i). More...
 
array as (dtype type) const
 
array asfloat () const
 Convert array to a floating point type(if not already). More...
 

Static Public Member Functions

template<typename ty >
static array scalar (const ty value)
 Push scalar value to the device. More...
 
template<typename T >
static Talloc (size_t elements)
 Allocate device memory array of elements. More...
 
static void * alloc (size_t elements, dtype type)
 Allocate device memory array of elements of type. More...
 
template<typename T >
static Tpinned (size_t elements)
 Allocate pinned host memory of elements (see free()). More...
 
static void free (const void *)
 

Data Fields

ginternalm_internal
 Pointer to internal data-structures. More...
 
dim4 m_dims
 Dimensions. More...
 
dtype m_type
 Data type. More...
 
unsigned m_ngfor
 Number of gfor tiles (zero or one indicates one tile) More...
 

Friends

class ginternal
 
std::ostream & operator<< (std::ostream &, const array &)
 
array operator+ (const double &, const array &)
 
array operator+ (const cfloat &, const array &)
 
array operator+ (const cdouble &, const array &)
 
array operator+ (const array &) const
 
array operator+ (const double &) const
 
array operator+ (const cfloat &) const
 
array operator+ (const cdouble &) const
 
array operator* (const double &, const array &)
 
array operator* (const cfloat &, const array &)
 
array operator* (const cdouble &, const array &)
 
array operator* (const array &) const
 
array operator* (const double &) const
 
array operator* (const cfloat &) const
 
array operator* (const cdouble &) const
 
array operator- (const double &, const array &)
 
array operator- (const cfloat &, const array &)
 
array operator- (const cdouble &, const array &)
 
array operator- (const array &) const
 
array operator- (const double &) const
 
array operator- (const cfloat &) const
 
array operator- (const cdouble &) const
 
array operator/ (const double &, const array &)
 
array operator/ (const cfloat &, const array &)
 
array operator/ (const cdouble &, const array &)
 
array operator/ (const array &) const
 
array operator/ (const double &) const
 
array operator/ (const cfloat &) const
 
array operator/ (const cdouble &) const
 
array operator% (const double &, const array &)
 
array operator% (const array &) const
 
array operator% (const double &) const
 
array operator&& (const bool &, const array &)
 
array operator&& (const int &, const array &)
 
array operator&& (const unsigned &, const array &)
 
array operator&& (const cfloat &, const array &)
 
array operator&& (const cdouble &, const array &)
 
array operator& (const array &) const
 
array operator&& (const array &) const
 
array operator&& (const bool &) const
 
array operator&& (const int &) const
 
array operator&& (const unsigned &) const
 
array operator&& (const double &) const
 
array operator&& (const cfloat &) const
 
array operator&& (const cdouble &) const
 
array operator|| (const bool &, const array &)
 
array operator|| (const int &, const array &)
 
array operator|| (const unsigned &, const array &)
 
array operator|| (const cfloat &, const array &)
 
array operator|| (const cdouble &, const array &)
 
array operator| (const array &) const
 
array operator|| (const array &) const
 
array operator|| (const bool &) const
 
array operator|| (const int &) const
 
array operator|| (const unsigned &) const
 
array operator|| (const double &) const
 
array operator|| (const cfloat &) const
 
array operator|| (const cdouble &) const
 
array operator== (const bool &, const array &)
 
array operator== (const int &, const array &)
 
array operator== (const double &, const array &)
 
array operator== (const cfloat &, const array &)
 
array operator== (const cdouble &, const array &)
 
array operator== (const array &) const
 
array operator== (const bool &) const
 
array operator== (const int &) const
 
array operator== (const double &) const
 
array operator== (const cfloat &) const
 
array operator== (const cdouble &) const
 
array operator!= (const bool &, const array &)
 
array operator!= (const int &, const array &)
 
array operator!= (const double &, const array &)
 
array operator!= (const cfloat &, const array &)
 
array operator!= (const cdouble &, const array &)
 
array operator!= (const array &) const
 
array operator!= (const bool &) const
 
array operator!= (const int &) const
 
array operator!= (const double &) const
 
array operator!= (const cfloat &) const
 
array operator!= (const cdouble &) const
 
array operator< (const bool &, const array &)
 
array operator< (const int &, const array &)
 
array operator< (const double &, const array &)
 
array operator< (const cfloat &, const array &)
 
array operator< (const cdouble &, const array &)
 
array operator< (const array &) const
 
array operator< (const bool &) const
 
array operator< (const int &) const
 
array operator< (const double &) const
 
array operator< (const cfloat &) const
 
array operator< (const cdouble &) const
 
array operator<= (const bool &, const array &)
 
array operator<= (const int &, const array &)
 
array operator<= (const double &, const array &)
 
array operator<= (const cfloat &, const array &)
 
array operator<= (const cdouble &, const array &)
 
array operator<= (const array &) const
 
array operator<= (const bool &) const
 
array operator<= (const int &) const
 
array operator<= (const double &) const
 
array operator<= (const cfloat &) const
 
array operator<= (const cdouble &) const
 
array operator> (const bool &, const array &)
 
array operator> (const int &, const array &)
 
array operator> (const double &, const array &)
 
array operator> (const cfloat &, const array &)
 
array operator> (const cdouble &, const array &)
 
array operator> (const array &) const
 
array operator> (const bool &) const
 
array operator> (const int &) const
 
array operator> (const double &) const
 
array operator> (const cfloat &) const
 
array operator> (const cdouble &) const
 
array operator>= (const bool &, const array &)
 
array operator>= (const int &, const array &)
 
array operator>= (const double &, const array &)
 
array operator>= (const cfloat &, const array &)
 
array operator>= (const cdouble &, const array &)
 
array operator>= (const array &) const
 
array operator>= (const bool &) const
 
array operator>= (const int &) const
 
array operator>= (const double &) const
 
array operator>= (const cfloat &) const
 
array operator>= (const cdouble &) const
 

Detailed Description

Constructor & Destructor Documentation

array ( ginternal )
~array ( )
array ( const array input,
const dim4 dims 
)

Adjust the dimensions of an N-D array (fast).

This operation simply rearranges the description of the array on the host device. No memory transfers or transformations are performed. The total number of elements must not change.

float f[] = {1,2,3,4};
array a(2,2,f);
//a=[1 3]
// [2 4]
array b = array(a, dim4(4));
//b=[1]
// [2]
// [3]
// [4]
array c = array(a, b.T().dims() );
//c=[1 2 3 4]
Parameters
[in]input
[in]dimstotal number of elements must not change.
Returns
same underlying array data with different dimensions
array ( const array input,
int  dim0,
int  dim1 = 1,
int  dim2 = 1,
int  dim3 = 1 
)

Adjust the dimensions of an N-D array (fast).

This operation simply rearranges the description of the array on the host device. No memory transfers or transformations are performed. The total number of elements must not change.

float f[] = {1,2,3,4};
array a(2,2,f);
//a=[1 3]
// [2 4]
array b = array(a, 4);
//b=[1]
// [2]
// [3]
// [4]
array c = array(a, 1, 4);
//c=[1 2 3 4]
Parameters
[in]input
[in]dim0first dimension
[in]dim1second dimension
[in]dim2third dimension
[in]dim3fourth dimension
Returns
same underlying array data with different dimensions

Member Function Documentation

array copy ( ) const

Create a deep-copy of another array for modification.

See device() for example.

array A(seq(3)); //A = [1 2 3]
array B = A.copy();
B -= 1;
//A = [1 2 3]
//B = [0 1 2]

Friends And Related Function Documentation

friend class ginternal
friend

Field Documentation

ginternal* m_internal
mutable

Pointer to internal data-structures.

dim4 m_dims

Dimensions.

dtype m_type

Data type.

unsigned m_ngfor

Number of gfor tiles (zero or one indicates one tile)


The documentation for this class was generated from the following file: