SparseLibrary
Version 1.6.0
|
The zig-zag compressed row storage sparse matrix data structure. More...
#include <ZZ_CRS.hpp>
Public Member Functions | |
ZZ_CRS () | |
Base constructor. More... | |
ZZ_CRS (std::string file, T zero=0) | |
Base constructor. More... | |
ZZ_CRS (const long int number_of_nonzeros, const long int number_of_rows, const long int number_of_cols, T zero) | |
Base constructor which only initialises the internal arrays. More... | |
ZZ_CRS (ZZ_CRS< T > &toCopy) | |
Copy constructor. More... | |
ZZ_CRS (std::vector< Triplet< T > > &input, const LI m, const LI 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 LI m, const LI n, const T zero) |
virtual void | getFirstIndexPair (LI &row, LI &col) |
Returns the first nonzero index, per reference. More... | |
virtual void | zxa (const T *x, T *z) |
In-place z=xA multiplication algorithm. More... | |
virtual void | zax (const T *__restrict__ x, T *__restrict z) |
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_CRS () | |
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... | |
virtual void | zax (const T *__restrict__ x, T *__restrict__ z)=0 |
In-place z=Ax function. More... | |
virtual void | zxa (const T *__restrict__ x, T *__restrict__ z)=0 |
In-place z=xA function. 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 | compareTripletsLTR (const Triplet< T > *one, const Triplet< T > *two) |
Comparison function used for sorting input data. More... | |
static bool | compareTripletsRTL (const Triplet< T > *one, const Triplet< T > *two) |
Comparison function used for sorting input data. More... | |
Protected Attributes | |
T * | ds |
Array containing the actual this->nnz non-zeros. More... | |
LI * | col_ind |
Array containing the column jumps. More... | |
LI * | row_start |
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 compressed row storage sparse matrix data structure.
Base constructor.
|
inline |
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_CRS< T, _i_value >::col_ind, ZZ_CRS< T, _i_value >::ds, SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::nor, and ZZ_CRS< T, _i_value >::row_start.
|
inline |
Copy constructor.
toCopy | reference to the CRS datastructure to copy. |
References ZZ_CRS< T, _i_value >::col_ind, ZZ_CRS< T, _i_value >::ds, SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::noc, SparseMatrix< T, LI >::nor, ZZ_CRS< T, _i_value >::row_start, 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_CRS< T, _i_value >::load().
Base deconstructor.
References ZZ_CRS< T, _i_value >::col_ind, ZZ_CRS< T, _i_value >::ds, and ZZ_CRS< T, _i_value >::row_start.
|
inlinevirtual |
Function to query the amount of storage required by this sparse matrix.
Implements Matrix< T >.
References SparseMatrix< T, LI >::nnz, and SparseMatrix< T, LI >::nor.
|
inlinestaticprotected |
Comparison function used for sorting input data.
References Triplet< T >::i(), and Triplet< T >::j().
Referenced by ZZ_CRS< T, _i_value >::load().
|
inlinestaticprotected |
Comparison function used for sorting input data.
References Triplet< T >::i(), and Triplet< T >::j().
Referenced by ZZ_CRS< T, _i_value >::load().
|
inlinevirtual |
Returns the first nonzero index, per reference.
Implements SparseMatrix< T, LI >.
References ZZ_CRS< T, _i_value >::col_ind, and ZZ_CRS< T, _i_value >::row_start.
|
inlinevirtual |
Implements SparseMatrix< T, LI >.
References ZZ_CRS< T, _i_value >::col_ind, ZZ_CRS< T, _i_value >::compareTripletsLTR(), ZZ_CRS< T, _i_value >::compareTripletsRTL(), ZZ_CRS< T, _i_value >::ds, Triplet< T >::i(), Triplet< T >::j(), SparseMatrix< T, LI >::m(), SparseMatrix< T, LI >::n(), SparseMatrix< T, LI >::nnz, SparseMatrix< T, LI >::noc, SparseMatrix< T, LI >::nor, ZZ_CRS< T, _i_value >::row_start, Triplet< T >::value, and SparseMatrix< T, LI >::zero_element.
Referenced by ZZ_CRS< T, _i_value >::ZZ_CRS().
|
inlinevirtual |
In-place z=Ax multiplication algorithm.
x | The vector x supplied for multiplication. |
z | The pre-allocated result vector. All elements should be set to zero in advance. |
References ZZ_CRS< T, _i_value >::col_ind, ZZ_CRS< T, _i_value >::ds, SparseMatrix< T, LI >::nor, and ZZ_CRS< T, _i_value >::row_start.
|
inlinevirtual |
In-place z=xA multiplication algorithm.
x | The vector x supplied for left-multiplication. |
z | The pre-allocated result vector. All elements should be set to zero in advance. |
References ZZ_CRS< T, _i_value >::col_ind, ZZ_CRS< T, _i_value >::ds, SparseMatrix< T, LI >::nor, and ZZ_CRS< T, _i_value >::row_start.
|
protected |
Array containing the column jumps.
Referenced by ZZ_CRS< T, _i_value >::getFirstIndexPair(), ZZ_CRS< T, _i_value >::load(), ZZ_CRS< T, _i_value >::zax(), ZZ_CRS< T, _i_value >::zxa(), ZZ_CRS< T, _i_value >::ZZ_CRS(), and ZZ_CRS< T, _i_value >::~ZZ_CRS().
|
protected |
Array containing the actual this->nnz non-zeros.
Referenced by ZZ_CRS< T, _i_value >::load(), ZZ_CRS< T, _i_value >::zax(), ZZ_CRS< T, _i_value >::zxa(), ZZ_CRS< T, _i_value >::ZZ_CRS(), and ZZ_CRS< T, _i_value >::~ZZ_CRS().
|
protected |
Array containing the row jumps.
Referenced by ZZ_CRS< T, _i_value >::getFirstIndexPair(), ZZ_CRS< T, _i_value >::load(), ZZ_CRS< T, _i_value >::zax(), ZZ_CRS< T, _i_value >::zxa(), ZZ_CRS< T, _i_value >::ZZ_CRS(), and ZZ_CRS< T, _i_value >::~ZZ_CRS().