CUDA
C/C++    Fortran   

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.
 array (ginternal *)
 ~array ()
 array ()
 Create non-dimensioned array (no data, undefined size).
 array (const dim4 &dims, dtype ty=f32)
 Allocate an array with undefined contents.
 array (int d0, int d1, dtype ty=f32)
 Allocate an array with undefined contents.
 array (int d0, int d1, int d2, dtype ty=f32)
 Allocate an array with undefined contents.
 array (int d0, int d1, int d2, int d3, dtype ty=f32)
 Allocate an array with undefined contents.
 array (const array &)
 Duplicate an existing array (copy constructor).
 array (const seq &s)
 Convert a seq object for use with arithmetic.
template<typename ty >
 array (unsigned dim0, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create column vector from pointer (column-major order like Fortran)
template<typename ty >
 array (unsigned dim0, unsigned dim1, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create matrix from pointer (column-major order like Fortran)
template<typename ty >
 array (unsigned dim0, unsigned dim1, unsigned dim2, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create volume from pointer (column-major order like Fortran)
template<typename ty >
 array (unsigned dim0, unsigned dim1, unsigned dim2, unsigned dim3, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create 4D array from pointer (column-major order like Fortran)
template<typename ty >
 array (const dim4 &dims, const ty *pointer, af_source_t src=afHost, unsigned ngfor=0)
 Create array from pointer (column-major order like Fortran)
 array (const array &input, const dim4 &dims)
 Adjust the dimensions of an N-D array (fast).
 array (const array &input, int dim0, int dim1=1, int dim2=1, int dim3=1)
 Adjust the dimensions of an N-D array (fast).
dim4 dims () const
 Fetch an object representing the dimensions of array.
int dims (unsigned) const
 Fetch size of specified dimension (zero-indexed).
int numdims () const
 How many dimensions (ignore trailing singletons)
int elements () const
 How many elements in array.
int nonzeros () const
 How many non zero elements in the array.
unsigned ngfor () const
 How many gfor() tiles (zero means none)
size_t bytes () const
 How many bytes (including all GFOR tiles) does this array occupy?
bool isempty () const
 Is empty (no elements)
bool isscalar () const
 Is scalar (one element)
bool isvector () const
 Is either row or column vector (or scalar), i.e.
bool isrow () const
 Is row vector.
bool iscolumn () const
 Is column vector.
dtype type () const
 Type of array dtype.
bool iscomplex () const
 Is complex-valued array?
bool isreal () const
 Is real-valued array?
bool issparse () const
void eval ()
 Evaluate an expression but do not block (wait) until complete.
void unlock () const
 Release pointers from device() after finished so can be garbage collected.
array row (int i) const
 Access row i to form row vector.
array col (int i) const
 Access column i to form column vector.
array slice (int i) const
 Access slice i to form a matrix (plane of a volume, channel in an image)
array rows (int first, int last) const
 Access rows first through last to form a matrix.
array cols (int first, int last) const
 Access columns first through last to form a matrix.
array slices (int first, int last) const
 Access slices first through last to form a volume.
array operator- () const
 Arithmetic negation.
array operator! () const
 Logical negation (not binary compliment)
array operator+ (const array &) const
array operator+ (const double &) const
array operator+ (const cuComplex &) const
array operator+ (const cuDComplex &) const
array operator* (const array &) const
array operator* (const double &) const
array operator* (const cuComplex &) const
array operator* (const cuDComplex &) const
array operator- (const array &) const
array operator- (const double &) const
array operator- (const cuComplex &) const
array operator- (const cuDComplex &) const
array operator/ (const array &) const
array operator/ (const double &) const
array operator/ (const cuComplex &) const
array operator/ (const cuDComplex &) const
array operator% (const array &) const
array operator% (const double &) const
arrayoperator+= (const array &)
arrayoperator+= (const double &)
arrayoperator+= (const cuComplex &)
arrayoperator+= (const cuDComplex &)
arrayoperator-= (const array &)
arrayoperator-= (const double &)
arrayoperator-= (const cuComplex &)
arrayoperator-= (const cuDComplex &)
arrayoperator*= (const array &)
arrayoperator*= (const double &)
arrayoperator*= (const cuComplex &)
arrayoperator*= (const cuDComplex &)
arrayoperator/= (const array &)
arrayoperator/= (const double &)
arrayoperator/= (const cuComplex &)
arrayoperator/= (const cuDComplex &)
arrayoperator%= (const array &)
arrayoperator%= (const double &)
arrayoperator++ ()
arrayoperator-- ()
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 cuComplex &) const
array operator&& (const cuDComplex &) const
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 cuComplex &) const
array operator|| (const cuDComplex &) const
array operator^ (const array &) const
array operator== (const array &) const
array operator== (const bool &) const
array operator== (const int &) const
array operator== (const double &) const
array operator== (const cuComplex &) const
array operator== (const cuDComplex &) const
array operator!= (const array &) const
array operator!= (const bool &) const
array operator!= (const int &) const
array operator!= (const double &) const
array operator!= (const cuComplex &) const
array operator!= (const cuDComplex &) const
array operator< (const array &) const
array operator< (const bool &) const
array operator< (const int &) const
array operator< (const double &) const
array operator< (const cuComplex &) const
array operator< (const cuDComplex &) const
array operator<= (const array &) const
array operator<= (const bool &) const
array operator<= (const int &) const
array operator<= (const double &) const
array operator<= (const cuComplex &) const
array operator<= (const cuDComplex &) const
array operator> (const array &) const
array operator> (const bool &) const
array operator> (const int &) const
array operator> (const double &) const
array operator> (const cuComplex &) const
array operator> (const cuDComplex &) const
array operator>= (const array &) const
array operator>= (const bool &) const
array operator>= (const int &) const
array operator>= (const double &) const
array operator>= (const cuComplex &) const
array operator>= (const cuDComplex &) const
template<typename ty >
arrayoperator= (const ty)
 scalar assignment
arrayoperator= (const array &)
 array assignment
array T () const
 Transpose matrix or vector.
array H () const
 Conjugate transpose (1+2i becomes 1-2i).
array as (dtype type) const
 Cast array's contents to the given type.
array asfloat () const
 Convert array to floating point (if not already). (from b8, s32, u32). No effect on f32, f64, c32, c64.
One subscript
array operator() (int x) const
 Access linear element x.
array operator() (const seq &) const
 Access linear sequence of elements.
array operator() (array indices) const
 Use indices (integer values or boolean mask)
Two subscripts
array operator() (const seq &, const seq &) const
 Access submatrix.
array operator() (int row, int col) const
 Access linear element at row and col.
array operator() (int row, const seq &y) const
 Access linear sequence of elements along row.
array operator() (int row, array columns) const
 Elements along row and columns.
array operator() (const seq &x, int column) const
 Access linear sequence of elements along column.
array operator() (const seq &rows, array columns) const
 Elements along rows and columns.
array operator() (array rows, int column) const
 Elements along rows and column.
array operator() (array rows, const seq &columns) const
 Elements along rows and columns.
array operator() (array rows, array columns) const
 Elements along rows and columns.
Three subscripts
array operator() (const seq &, const seq &, const seq &) const
 Access volume.
array operator() (int x, int y, int z) const
 Access element.
array operator() (const seq &x, int y, int z) const
 Access vector.
array operator() (int x, const seq &y, int z) const
 Access vector.
array operator() (int x, int y, const seq &z) const
 Access vector.
array operator() (int x, const seq &y, const seq &z) const
 Access matrix.
array operator() (const seq &x, const seq &y, int z) const
 Access matrix.
array operator() (const seq &x, int y, const seq &z) const
 Access matrix.
array operator() (array rows, array cols, const seq &slices) const
 Elements along rows, columns, slices.
array operator() (array rows, array cols, int slice) const
 Elements along rows, cols, slice.
array operator() (array rows, const seq &cols, const seq &slices) const
 Elements along rows, columns, slices.
array operator() (array rows, const seq &cols, int slice) const
 Elements along rows, cols, slice.
array operator() (const seq &rows, array cols, const seq &slices) const
 Elements along rows, columns, slices.
array operator() (const seq &, const seq &, array) const
 Access submatrix.
Four subscripts
array operator() (const seq &w, const seq &x, const seq &y, const seq &z) const
 Access volume.
array operator() (const seq &w, const seq &x, const seq &y, int z) const
 Access volume.
array operator() (const seq &w, const seq &x, int y, int z) const
 Access matrix.

Static Public Member Functions

template<typename ty >
static array scalar (const ty)
 Push scalar value to the device.

Data Fields

ginternal * m_internal

Friends

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

template<typename T >
scalar () const
 Returns host-side scalar of first component of data.
template<typename T >
T * device () const
 Device-side pointer to matrix data.
template<typename T >
T * host () const
 Host-side pointer to matrix data.
void host (void *ptr) const
 Copy device data to host-side pointer.
template<typename T >
static T * alloc (size_t elements)
 Allocate device memory array of elements (see free()).
static void * alloc (size_t elements, dtype type)
 Allocate device memory array of elements of type (see free()).
template<typename T >
static T * pinned (size_t elements)
 Allocate pinned host memory of elements (see free()).
static void free (const void *)
 Free data allocated by alloc() or returned from host()

Detailed Description


Constructor & Destructor Documentation

array ( ginternal *  )
~array ( )

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]
Examples:
examples/machine_learning/geneticalgorithm.cpp.
void eval ( )

Evaluate an expression but do not block (wait) until complete.

Examples:
examples/benchmarks/blas.cpp.
void unlock ( ) const

Release pointers from device() after finished so can be garbage collected.

array as ( dtype  type) const

Cast array's contents to the given type.

       array a( seq(1, 0.5, 2) ); // a=[1.0 1.5 2.0]

       array b = a.as(u32); // b=[1 1 2]

type

array asfloat ( ) const

Convert array to floating point (if not already). (from b8, s32, u32). No effect on f32, f64, c32, c64.

Examples:
examples/machine_learning/geneticalgorithm.cpp.

Friends And Related Function Documentation

friend class ginternal [friend]
std::ostream& operator<< ( std::ostream &  ,
const array  
) [friend]

Field Documentation

ginternal* m_internal [mutable]

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