Namespace Array

namespace array

Functions

af::array createArray(const void *data, unsigned ndims, const dim_t *dims, int type)

Creates an af::array.

Return
af::array Containing the data.
Parameters
  • data: Data used to create the af::array.
  • ndims: Number of dimensions of data.
  • dims: Cardinality of dimensions of data.
  • type: Data type.

void deleteArray(af_array array)

Decreases the references count for the given array.

Parameters
  • array: The Array to be deleted.

void getData(const af::array &array, void *data)

Retrieves the data from the device to the host.

Parameters
  • array: The Array that contains the data to be retrieved.
  • data: Pointer to a preallocated block of memory in the host.

af::dim4 getDims(const af::array &array)

Returns the dimensions from a given array.

Return
af::dim4 The dimensions.
Parameters
  • array: Array from which to get the dimensions.

int getType(const af::array &array)

Gets the type of the array.

Return
int Value of the Dtype enumeration.
Parameters
  • array: The array to obtain the type from.

af::array join(int dim, const af::array &first, const af::array &second)

Joins the first and second arrays along the specified dimension.

Return
af::array The result of joining first and second along the specified dimension.
Parameters
  • dim: The dimension along which the join occurs.
  • first: The first input array.
  • second: The second input array.

void print(const af::array &array)

Prints the content of an array.

Parameters
  • array: The array to be printed.

af::array from_af_array(const af_array array)

Creates an af::array from its af_array C pointer. The resulting array does not acquire the input pointer passed. User of this function is responsible to release it.

Parameters
  • array: The array to be printed.

af_array increment_ref_count(const af_array array)

Increments the reference count of the af_array C pointer passed throwing if there is an error. The user of this function is responsible to release the returned array by calling deleteArray.

Parameters
  • array: The array whose reference count is going to be incremented.

template <typename T>
std::vector<int> getRowsWithMaximals(const khiva::array::Array<T> &a)

Gets the indices of all rows containing a maximal.

Return
std::vector<int> with the indices of the rows with maximals.
Parameters
  • a: The input array.

template <typename T>
std::vector<int> getIndexMaxColumns(const std::vector<T> &r)

Gets the indices of the columns with maximals.

Return
std::vector<int> with the indices of the columns with maximals.
Parameters
  • r: The input row.

template <class T>
class Array
#include </home/docs/checkouts/readthedocs.org/user_builds/khiva/checkouts/latest/include/khiva/array.h>

Array class, This class provides functionality manage Arrays on the host side.

Public Functions

Array()

Default Constructor of Array class.

Array(const af::array &in)

Constructor of Array class which receives and af::array.

Parameters
  • in: The input af::array.

~Array()

Default destructor of Array class.

void setNumX(int val)

Sets the cardinality of the first dimension.

Parameters
  • val: The value to be set.

void setNumY(int val)

Sets the cardinality of the second dimension.

Parameters
  • val: The value to be set.

void setNumW(int val)

Sets the cardinality of the third dimension.

Parameters
  • val: The value to be set.

void setNumZ(int val)

Sets the cardinality of the fourth dimension.

Parameters
  • val: The value to be set.

void setData(T *pd)

Sets the data to be stored in the Array.

Parameters
  • pd: The data to be stored.

int getNumX() const

Gets the cardinality of the first dimension.

Return
int the Cardinality of the first dimension.

int getNumY() const

Gets the cardinality of the second dimension.

Return
int the Cardinality of the second dimension.

int getNumW() const

Gets the cardinality of the third dimension.

Return
int the Cardinality of the third dimension.

int getNumZ() const

Gets the cardinality of the fourth dimension.

Return
int the Cardinality of the fourth dimension.

int getNumElements() const

Gets the number of elements in data.

Return
int the Cardinality of the number of elements.

std::vector<T> getRow(int idx) const

Gets the row number given by idx.

Return
std::vector Containing the selected row.
Parameters
  • idx: The row number to be extracted.

std::vector<T> getColumn(int idx) const

Gets the column number given by idx.

Return
std::vector Containing the selected column.
Parameters
  • idx: The column number to be extracted.

T getElement(int row, int column) const

Gets the element given by row and column.

Return
T The element to be extracted.
Parameters
  • row: The row number.
  • column: The column number.

T *getData()

Gets a pointer to the data stored in the array.

Return
T Pointer to data.

bool isEmpty()

Checks whether The Array is empty or not.

Return
True if the Array is empty, false otherwise.

void print()

Prints the content of the array.