SparseLibrary
Version 1.6.0
|
The zig-zag incremental compressed row storage sparse matrix data structure. More...
#include <ZZ_ICRS.hpp>
Public Member Functions | |
ZZ_ICRS () | |
Base constructor. More... | |
ZZ_ICRS (std::string file, T zero=0) | |
Base constructor. More... | |
ZZ_ICRS (const myULI number_of_nonzeros, const myULI number_of_rows, const myULI number_of_cols, T zero) | |
Base constructor which only initialises the internal arrays. More... | |
ZZ_ICRS (ZZ_ICRS< T > &toCopy) | |
Copy constructor. More... | |
ZZ_ICRS (std::vector< Triplet< T > > &input, const myULI m, const myULI n, const T zero) | |
Constructor which transforms a collection of input triplets to CRS format. More... | |
virtual void | load (std::vector< Triplet< T > > &input, const myULI m, const myULI n, const T zero) |
virtual void | getFirstIndexPair (myULI &row, myULI &col) |
Returns the first nonzero index, per reference. More... | |
virtual void | zxa (const T *__restrict__ pDataX, T *__restrict__ pDataZ) |
In-place z=xA multiplication algorithm. More... | |
virtual void | zax (const T *__restrict__ pDataX, T *__restrict__ pDataZ) |
In-place z=Ax multiplication algorithm. More... | |
virtual size_t | bytesUsed () |
Function to query the amount of storage required by this sparse matrix. More... | |
~ZZ_ICRS () | |
Base deconstructor. More... | |
Public Member Functions inherited from SparseMatrix< T, LI > | |
SparseMatrix () | |
Base constructor. More... | |
SparseMatrix (const LInzs, const LInr, const LInc, const T zero) | |
Base constructor. More... | |
virtual | ~SparseMatrix () |
Base deconstructor. More... | |
void | loadFromFile (const std::string file, const T zero=0) |
Function which loads a matrix from a matrix market file. More... | |
virtual unsigned long int | m () |
Queries the number of rows this matrix contains. More... | |
virtual unsigned long int | n () |
Queries the number of columns this matrix contains. More... | |
virtual unsigned long int | nzs () |
Queries the number of nonzeroes stored in this matrix. More... | |
virtual T * | mv (const T *x) |
Calculates and returns z=Ax. More... | |
Public Member Functions inherited from Matrix< T > | |
Matrix () | |
Base constructor. More... | |
virtual | ~Matrix () |
Base deconstructor. More... | |
virtual void | zax (const T *__restrict__ x, T *__restrict__ z, const size_t k, const clockid_t clock_id=0, double *elapsed_time=NULL) |
Wrapper function to call the zax kernel multiple times successively, while timing the duration of the operation. More... | |
template<size_t k> | |
void | ZaX (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z) |
In-place Z=AX function, where A is m x n, Z = m x k, and X is n x k. More... | |
template<size_t k> | |
void | ZXa (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z) |
In-place Z=XA function, where A is m x n, Z = k x n, and X is k x m. More... | |
virtual void | zxa (const T *__restrict__ x, T *__restrict__ z, const unsigned long int repeat, const clockid_t clock_id=0, double *elapsed_time=NULL) |
Wrapper function to call the zxa kernel multiple times successively, while timing the operation duration. More... | |
Static Protected Member Functions | |
static bool | compareTriplets (const Triplet< T > &one, const Triplet< T > &two) |
Comparison function used for sorting input data. More... | |
Protected Attributes | |
size_t | jumps |
The number of row jumps. More... | |
T * | ds |
Array containing the actual this->nnz non-zeros. More... | |
myULI * | c_ind |
Array containing the column jumps. More... | |
myULI * | r_ind |
Array containing the row jumps. More... | |
Protected Attributes inherited from SparseMatrix< T, LI > | |
LI | nor |
Number of rows. More... | |
LI | noc |
Number of columns. | |
LI | nnz |
Number of non-zeros. More... | |
Additional Inherited Members | |
Public Attributes inherited from SparseMatrix< T, LI > | |
T | zero_element |
The element considered to be zero. More... | |
The zig-zag incremental compressed row storage sparse matrix data structure.
Base constructor.
Will read in from Matrix Market file.
References SparseMatrix< T, LI >::loadFromFile().
|
inline |
Base constructor which only initialises the internal arrays.
Note that to gain a valid CRS structure, these arrays have to be filled by some external mechanism (i.e., after calling this constructor, the internal arrays contain garbage, resuling in invalid datastructure).
number_of_nonzeros | The number of non-zeros to be stored. |
number_of_rows | The number of rows to be stored. |
number_of_cols | The number of columns to be stored. |
zero | Which element is considered to be the zero element. |
References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, SparseMatrix< T, LI >::nnz, and ZZ_ICRS< T >::r_ind.
Copy constructor.
toCopy | reference to the CRS datastructure to copy. |
References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::noc, SparseMatrix< T, LI >::nor, ZZ_ICRS< T >::r_ind, and SparseMatrix< T, LI >::zero_element.
|
inline |
Constructor which transforms a collection of input triplets to CRS format.
The input collection is considered to have at most one triplet with unique pairs of indeces. Unspecified behaviour occurs when this assumption is not met.
input | The input collection. |
m | Total number of rows. |
n | Total number of columns. |
zero | Which element is considered zero. |
References ZZ_ICRS< T >::load().
Base deconstructor.
References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, and ZZ_ICRS< T >::r_ind.
|
inlinevirtual |
Function to query the amount of storage required by this sparse matrix.
Implements Matrix< T >.
References ZZ_ICRS< T >::jumps, and SparseMatrix< T, LI >::nnz.
|
inlinestaticprotected |
Comparison function used for sorting input data.
References Triplet< T >::i(), and Triplet< T >::j().
Referenced by ZZ_ICRS< T >::load().
|
inlinevirtual |
Returns the first nonzero index, per reference.
Implements SparseMatrix< T, LI >.
References ZZ_ICRS< T >::c_ind, and ZZ_ICRS< T >::r_ind.
|
inlinevirtual |
Implements SparseMatrix< T, LI >.
References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::compareTriplets(), ZZ_ICRS< T >::ds, Triplet< T >::i(), Triplet< T >::j(), ZZ_ICRS< T >::jumps, SparseMatrix< T, LI >::m(), SparseMatrix< T, LI >::n(), SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::noc, SparseMatrix< T, LI >::nor, ZZ_ICRS< T >::r_ind, Triplet< T >::value, and SparseMatrix< T, LI >::zero_element.
Referenced by ZZ_ICRS< T >::ZZ_ICRS().
|
inlinevirtual |
In-place z=Ax multiplication algorithm.
pDataX | The vector x supplied for multiplication. |
pDataZ | The pre-allocated result vector. All elements should be set to zero in advance. |
Implements SparseMatrix< T, LI >.
References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::noc, SparseMatrix< T, LI >::nor, and ZZ_ICRS< T >::r_ind.
|
inlinevirtual |
In-place z=xA multiplication algorithm.
pDataX | The vector x supplied for left-multiplication. |
pDataZ | The pre-allocated result vector. All elements should be set to zero in advance. |
Implements SparseMatrix< T, LI >.
References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::noc, SparseMatrix< T, LI >::nor, and ZZ_ICRS< T >::r_ind.
|
protected |
Array containing the column jumps.
Referenced by ZZ_ICRS< T >::getFirstIndexPair(), ZZ_ICRS< T >::load(), ZZ_ICRS< T >::zax(), ZZ_ICRS< T >::zxa(), ZZ_ICRS< T >::ZZ_ICRS(), and ZZ_ICRS< T >::~ZZ_ICRS().
|
protected |
Array containing the actual this->nnz non-zeros.
Referenced by ZZ_ICRS< T >::load(), ZZ_ICRS< T >::zax(), ZZ_ICRS< T >::zxa(), ZZ_ICRS< T >::ZZ_ICRS(), and ZZ_ICRS< T >::~ZZ_ICRS().
|
protected |
The number of row jumps.
Referenced by ZZ_ICRS< T >::bytesUsed(), and ZZ_ICRS< T >::load().
|
protected |
Array containing the row jumps.
Referenced by ZZ_ICRS< T >::getFirstIndexPair(), ZZ_ICRS< T >::load(), ZZ_ICRS< T >::zax(), ZZ_ICRS< T >::zxa(), ZZ_ICRS< T >::ZZ_ICRS(), and ZZ_ICRS< T >::~ZZ_ICRS().