array Class Reference

A multi dimensional data container. More...

#include <array.h>

Data Structures

class  array_proxy
 Intermediate data class. More...
 

Public Member Functions

void set (af_array tmp)
 Updates the internal af_array object. More...
 
template<typename T >
Tdevice () const
 
array::array_proxy operator() (const index &s0)
 This operator returns a reference of the original array at a given coordinate. More...
 
const array::array_proxy operator() (const index &s0) const
 This operator returns a reference of the original array at a given coordinate. More...
 
array::array_proxy operator() (const index &s0, const index &s1, const index &s2=span, const index &s3=span)
 This operator returns a reference of the original array at a given coordinate. More...
 
const array::array_proxy operator() (const index &s0, const index &s1, const index &s2=span, const index &s3=span) const
 This operator returns a reference of the original array at a given coordinate. More...
 
const array as (dtype type) const
 Converts the array into another type. More...
 
 ~array ()
 
array T () const
 Get the transposed the array. More...
 
array H () const
 Get the conjugate-transpose of the current array. More...
 
array operator- () const
 Negates the values of the array. More...
 
array operator! () const
 Performs a not operation on the values of the array. More...
 
int nonzeros () const
 Get the count of non-zero elements in the array. More...
 
void lock () const
 Locks the device buffer in the memory manager. More...
 
bool isLocked () const
 Query if the array has been locked by the user. More...
 
void unlock () const
 Unlocks the device buffer in the memory manager. More...
 
 array ()
 Create undimensioned array (no data, undefined size) More...
 
 array (const af_array handle)
 Creates an array from an af_array handle. More...
 
 array (const array &in)
 Creates a copy to the in array. More...
 
 array (dim_t dim0, dtype ty=f32)
 Allocate a one-dimensional array of a specified size with undefined contents. More...
 
 array (dim_t dim0, dim_t dim1, dtype ty=f32)
 Allocate a two-dimensional array of a specified size with undefined contents. More...
 
 array (dim_t dim0, dim_t dim1, dim_t dim2, dtype ty=f32)
 Allocate a three-dimensional (3D) array of a specified size with undefined contents. More...
 
 array (dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, dtype ty=f32)
 Allocate a four-dimensional (4D) array of a specified size with undefined contents. More...
 
 array (const dim4 &dims, dtype ty=f32)
 Allocate an array of a specified size with undefined contents. More...
 
template<typename T >
 array (dim_t dim0, const T *pointer, af::source src=afHost)
 Create a column vector on the device using a host/device pointer. More...
 
template<typename T >
 array (dim_t dim0, dim_t dim1, const T *pointer, af::source src=afHost)
 Create a 2D array on the device using a host/device pointer. More...
 
template<typename T >
 array (dim_t dim0, dim_t dim1, dim_t dim2, const T *pointer, af::source src=afHost)
 Create a 3D array on the device using a host/device pointer. More...
 
template<typename T >
 array (dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, const T *pointer, af::source src=afHost)
 Create a 4D array on the device using a host/device pointer. More...
 
template<typename T >
 array (const dim4 &dims, const T *pointer, af::source src=afHost)
 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, const dim_t dim0, const dim_t dim1=1, const dim_t dim2=1, const dim_t dim3=1)
 Adjust the dimensions of an N-D array (fast). More...
 
af_array get ()
 get the af_array handle More...
 
af_array get () const
 get the af_array handle More...
 
dim_t elements () const
 get the number of elements in array More...
 
template<typename T >
Thost () const
 Copy array data to host and return host pointer. More...
 
void host (void *ptr) const
 Copy array data to existing host pointer. More...
 
template<typename T >
void write (const T *ptr, const size_t bytes, af::source src=afHost)
 Perform deep copy from host/device pointer to an existing array. More...
 
dtype type () const
 Get array data type. More...
 
dim4 dims () const
 Get dimensions of the array. More...
 
dim_t dims (unsigned dim) const
 Get dimensions of the array. More...
 
unsigned numdims () const
 Get the number of dimensions of the array. More...
 
size_t bytes () const
 Get the size of the array in bytes. More...
 
size_t allocated () const
 Get the size of the array in memory. More...
 
array copy () const
 Perform deep copy of the array. More...
 
bool isempty () const
 Returns true of the array is empty. More...
 
bool isscalar () const
 Returns true of the array contains only one value. More...
 
bool isvector () const
 Returns true if only one of the array dimensions has more than one element. More...
 
bool isrow () const
 Returns true if only the second dimension has more than one element. More...
 
bool iscolumn () const
 Returns true if only the first dimension has more than one element. More...
 
bool iscomplex () const
 Returns true if the array type is c32 or c64. More...
 
bool isreal () const
 Returns true if the array type is neither c32 nor c64. More...
 
bool isdouble () const
 Returns true if the array type is f64 or c64. More...
 
bool issingle () const
 Returns true if the array type is neither f64 nor c64. More...
 
bool isrealfloating () const
 Returns true if the array type is f32 or f64. More...
 
bool isfloating () const
 Returns true if the array type is f32, f64, c32 or c64. More...
 
bool isinteger () const
 Returns true if the array type is u8, b8, s32 u32, s64, u64, s16, u16. More...
 
bool isbool () const
 Returns true if the array type is b8. More...
 
bool issparse () const
 Returns true if the array is a sparse array. More...
 
void eval () const
 Evaluate any JIT expressions to generate data for the array. More...
 
template<typename T >
T scalar () const
 Get the first element of the array as a scalar. More...
 
array::array_proxy row (int index)
 Returns a reference to a row. More...
 
const array::array_proxy row (int index) const
 Returns a reference to a row. More...
 
array::array_proxy rows (int first, int last)
 Returns a reference to sequence of rows. More...
 
const array::array_proxy rows (int first, int last) const
 Returns a reference to sequence of rows. More...
 
array::array_proxy col (int index)
 Returns a reference to a col. More...
 
const array::array_proxy col (int index) const
 Returns a reference to a col. More...
 
array::array_proxy cols (int first, int last)
 Returns a reference to sequence of columns. More...
 
const array::array_proxy cols (int first, int last) const
 Returns a reference to sequence of columns. More...
 
array::array_proxy slice (int index)
 Returns a reference to a matrix in a volume. More...
 
const array::array_proxy slice (int index) const
 Returns a reference to a matrix in a volume. More...
 
array::array_proxy slices (int first, int last)
 Returns a reference to a matrix in a volume. More...
 
const array::array_proxy slices (int first, int last) const
 Returns a reference to a matrix in a volume. More...
 
arrayoperator= (const array &val)
 Assignes the value(s) of val to the elements of the array. More...
 
arrayoperator= (const double &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const cdouble &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const cfloat &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const float &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const int &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const unsigned &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const bool &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const char &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const unsigned char &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const long &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const unsigned long &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const long long &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const unsigned long long &val)
 
arrayoperator= (const short &val)
 Assignes the value(s) of val to the elements of the array.
More...
 
arrayoperator= (const unsigned short &val)
 
arrayoperator+= (const array &val)
 Adds the value(s) of val to the elements of the array. More...
 
arrayoperator+= (const double &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const cdouble &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const cfloat &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const float &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const int &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const unsigned &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const bool &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const char &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const unsigned char &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const long &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const unsigned long &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const long long &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const unsigned long long &val)
 
arrayoperator+= (const short &val)
 Adds the value(s) of val to the elements of the array.
More...
 
arrayoperator+= (const unsigned short &val)
 
arrayoperator-= (const array &val)
 Subtracts the value(s) of val to the elements of the array. More...
 
arrayoperator-= (const double &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const cdouble &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const cfloat &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const float &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const int &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const unsigned &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const bool &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const char &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const unsigned char &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const long &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const unsigned long &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const long long &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const unsigned long long &val)
 
arrayoperator-= (const short &val)
 Subtracts the value(s) of val to the elements of the array.
More...
 
arrayoperator-= (const unsigned short &val)
 
arrayoperator*= (const array &val)
 Multiplies the value(s) of val to the elements of the array. More...
 
arrayoperator*= (const double &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const cdouble &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const cfloat &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const float &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const int &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const unsigned &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const bool &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const char &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const unsigned char &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const long &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const unsigned long &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const long long &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const unsigned long long &val)
 
arrayoperator*= (const short &val)
 Multiplies the value(s) of val to the elements of the array.
More...
 
arrayoperator*= (const unsigned short &val)
 
arrayoperator/= (const array &val)
 Divides the value(s) of val to the elements of the array. More...
 
arrayoperator/= (const double &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const cdouble &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const cfloat &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const float &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const int &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const unsigned &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const bool &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const char &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const unsigned char &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const long &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const unsigned long &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const long long &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const unsigned long long &val)
 
arrayoperator/= (const short &val)
 Divides the value(s) of val to the elements of the array.
More...
 
arrayoperator/= (const unsigned short &val)
 

Detailed Description

A multi dimensional data container.

Examples:
benchmarks/blas.cpp, benchmarks/cg.cpp, benchmarks/fft.cpp, benchmarks/pi.cpp, computer_vision/fast.cpp, computer_vision/harris.cpp, computer_vision/matching.cpp, computer_vision/susan.cpp, financial/black_scholes_options.cpp, financial/heston_model.cpp, financial/monte_carlo_options.cpp, getting_started/convolve.cpp, getting_started/integer.cpp, getting_started/rainfall.cpp, getting_started/vectorize.cpp, graphics/conway.cpp, graphics/conway_pretty.cpp, graphics/field.cpp, graphics/fractal.cpp, graphics/gravity_sim.cpp, graphics/histogram.cpp, graphics/plot2d.cpp, graphics/plot3.cpp, graphics/surface.cpp, helloworld/helloworld.cpp, image_processing/adaptive_thresholding.cpp, image_processing/binary_thresholding.cpp, image_processing/brain_segmentation.cpp, image_processing/edge.cpp, image_processing/filters.cpp, image_processing/gradient_diffusion.cpp, image_processing/image_demo.cpp, image_processing/image_editing.cpp, image_processing/morphing.cpp, image_processing/optical_flow.cpp, image_processing/pyramids.cpp, lin_algebra/cholesky.cpp, lin_algebra/lu.cpp, lin_algebra/qr.cpp, lin_algebra/svd.cpp, machine_learning/bagging.cpp, machine_learning/deep_belief_net.cpp, machine_learning/geneticalgorithm.cpp, machine_learning/kmeans.cpp, machine_learning/knn.cpp, machine_learning/logistic_regression.cpp, machine_learning/naive_bayes.cpp, machine_learning/neural_network.cpp, machine_learning/perceptron.cpp, machine_learning/rbm.cpp, machine_learning/softmax_regression.cpp, pde/swe.cpp, and unified/basic.cpp.

Definition at line 26 of file array.h.

Constructor & Destructor Documentation

◆ ~array()

~array ( )

Member Function Documentation

◆ isLocked()

bool isLocked ( ) const

Query if the array has been locked by the user.

An array can be locked by the user by calling arry.lock or arr.device or getRawPtr function.

◆ lock()

void lock ( ) const

Locks the device buffer in the memory manager.

This method can be called to take control of the device pointer from the memory manager. While a buffer is locked, the memory manager doesn't free the memory until unlock() is invoked.

◆ nonzeros()

int nonzeros ( ) const

Get the count of non-zero elements in the array.

For dense matrix, this is the same as count<int>(arr);

◆ set()

void set ( af_array  tmp)

Updates the internal af_array object.

Note
This function will reduce the reference of the previous af_array object

◆ unlock()

void unlock ( ) const

Unlocks the device buffer in the memory manager.

This method can be called after called after calling array::lock() Calling this method gives back the control of the device pointer to the memory manager.


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