Template Class CSRArray

Class Documentation

template<typename T>
class CSRArray

Public Functions

CSRArray()

Construct a new Sparse Row Array object.

CSRArray(CArray<T> array, CArray<size_t> column_index, CArray<size_t> start_index, size_t dim1, size_t dim2)

Construct a new Sparse Row Array object.

Parameters
  • array – 1d array of data values in order read left to right top to bottom

  • column_index_ – 1d array specifying for each data value what column it is found

  • start_index_ – 1d array that marks the index for array and column where each row starts

  • dim1 – number of rows

  • dim2 – number of columns

CSRArray(CArray<T> dense)

Constructor for a new Sparse Row Array object using the data from a dense matrix.

Parameters

dense – matrix to get the value from

CSRArray(const CSRArray &temp)

Copy a new Sparse Row Array object.

Parameters

temp – array to copy

T &operator()(size_t i, size_t j) const

Access A(i,j). Returns a dummy address with value 0 if A(i,j) is not alocated.

Parameters
  • i – row

  • j – column

Returns

T&

T &value(size_t i, size_t j) const

Same functionality as operator(). Used for compatibility with other matar types.

Parameters
  • i – Row

  • j – Column

Returns

T&

CSRArray &operator=(const CSRArray &temp)

Assignment operator. Uses shared pointers to the data of temp instead of making a fresh copy.

Parameters

tempCSRArray to copy values of

Returns

CSRArray&

T *pointer() const

get start of array_ data

Returns

T*

size_t *get_starts() const

Get the start_index_ object.

Returns

size_t*

void printer()
T *begin(size_t i)

Iterator notation to go through the non zero values of row i.

Parameters

i – row

Returns

T* pointer to first non zero element of row i

T *end(size_t i)

Iterator notation to go through the non zeros values of row i.

Parameters

i – row

Returns

T* pointer to first non zero element of row i+1

size_t stride(size_t i) const

Return number of non zero elements in row i. Included for compatibility with other matar types.

Parameters

i – row

size_t dim1() const

Number of rows.

size_t dim2() const

Number of Columns.

size_t begin_index(size_t i)
size_t end_index(size_t i)
size_t nnz(size_t i)
size_t nnz()
T &get_val_flat(size_t k)
size_t get_col_flat(size_t k)
size_t flat_index(size_t i, size_t j)
int toCSC(CArray<T> &array, CArray<size_t> &start_index, CArray<size_t> &row_index)
void to_dense(CArray<T> &A)
~CSRArray()