SparseLibrary
Version 1.6.0
|
The incremental compressed row storage sparse matrix data structure. More...
#include <ICRS.hpp>
Public Member Functions | |
ICRS () | |
Base constructor. More... | |
ICRS (std::string file, T zero=0) | |
Base constructor. More... | |
ICRS (const ULI number_of_nonzeros, const ULI number_of_rows, const ULI number_of_cols, T zero) | |
Base constructor which only initialises the internal arrays. More... | |
ICRS (ICRS< T > &toCopy) | |
Copy constructor. More... | |
ICRS (std::vector< Triplet< T > > &input, const ULI m, const ULI n, const T zero=0) | |
Constructor which transforms a collection of input triplets to CRS format. More... | |
virtual void | load (std::vector< Triplet< T > > &input, const ULI m, const ULI n, const T zero) |
virtual void | getFirstIndexPair (ULI &row, ULI &col) |
Returns the first nonzero index, per reference. More... | |
void | getStartingPos (ULI &row_start, ULI &column_start) |
Gets starting position (first nonzero location) | |
void | setStartingPos (const ULI row_start, const ULI column_start) |
Sets starting position of matrix multiplication. More... | |
virtual void | zxa (const T *__restrict__ pDataX, T *__restrict__ pDataZ) |
In-place z=xA function. More... | |
virtual void | zax (const T *__restrict__ pDataX, T *__restrict__ pDataZ) |
In-place z=Ax function. More... | |
template<size_t k> | |
void | ZaX (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z) |
template<size_t k> | |
void | ZXa (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z) |
~ICRS () | |
Base deconstructor. More... | |
virtual size_t | bytesUsed () |
Function to query the amount of storage required by this sparse matrix. More... | |
Public Member Functions inherited from SparseMatrix< T, ULI > | |
SparseMatrix () | |
Base constructor. More... | |
SparseMatrix (const ULInzs, const ULInr, const ULInc, 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 Public Member Functions | |
static int | compareTriplets (const void *left, const void *right) |
Comparison function used for sorting input data. More... | |
Static Public Attributes | |
static const size_t | fillIn = 0 |
Fill-in field for interoperability with vecBICRS. More... | |
Protected Attributes | |
T * | ds |
Array containing the actual nnz non-zeros. More... | |
ULI | r_start |
Start position, row. | |
ULI | c_start |
Start position, column. | |
_i_value * | c_ind |
Array containing the column jumps. More... | |
_i_value * | r_ind |
Array containing the row jumps. More... | |
size_t | bytes |
Remembers the number of bytes allocated. More... | |
Protected Attributes inherited from SparseMatrix< T, ULI > | |
ULI | nor |
Number of rows. More... | |
ULI | noc |
Number of columns. | |
ULI | nnz |
Number of non-zeros. More... | |
Additional Inherited Members | |
Public Attributes inherited from SparseMatrix< T, ULI > | |
T | zero_element |
The element considered to be zero. More... | |
The incremental compressed row storage sparse matrix data structure.
Base constructor.
|
inline |
Base constructor.
Will read in from Matrix Market file.
References SparseMatrix< T, ULI >::loadFromFile().
|
inline |
Base constructor which only initialises the internal arrays.
Note that to gain a valid ICRS 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 of the matrix to be stored. |
number_of_cols | The number of columns of the matrix to be stored. |
zero | Which element is considered to be the zero element. |
References ICRS< T, _i_value >::bytes, ICRS< T, _i_value >::c_ind, ICRS< T, _i_value >::ds, SparseMatrix< T, ULI >::nnz, and ICRS< T, _i_value >::r_ind.
|
inline |
Copy constructor.
toCopy | Reference to the ICRS datastructure to copy. |
References ICRS< T, _i_value >::bytes, ICRS< T, _i_value >::c_ind, ICRS< T, _i_value >::c_start, ICRS< T, _i_value >::ds, SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, ICRS< T, _i_value >::r_ind, ICRS< T, _i_value >::r_start, and SparseMatrix< T, ULI >::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 indices. Unspecified behaviour occurs when this assumption is not met.
input | The input collection of triplets (i,j,val). |
m | The number of rows of the input matrix. |
n | The number of columns of the input matrix. |
zero | Which element is considered zero. |
References ICRS< T, _i_value >::load().
Base deconstructor.
References ICRS< T, _i_value >::c_ind, ICRS< T, _i_value >::ds, and ICRS< T, _i_value >::r_ind.
|
inlinevirtual |
Function to query the amount of storage required by this sparse matrix.
Implements Matrix< T >.
References ICRS< T, _i_value >::bytes.
|
inlinestatic |
Comparison function used for sorting input data.
References Triplet< T >::i(), and Triplet< T >::j().
Referenced by ICRS< T, _i_value >::load().
|
inlinevirtual |
Returns the first nonzero index, per reference.
Implements SparseMatrix< T, ULI >.
References ICRS< T, _i_value >::c_start, and ICRS< T, _i_value >::r_start.
|
inlinevirtual |
Implements SparseMatrix< T, ULI >.
References ICRS< T, _i_value >::bytes, ICRS< T, _i_value >::c_ind, ICRS< T, _i_value >::c_start, ICRS< T, _i_value >::compareTriplets(), ICRS< T, _i_value >::ds, Triplet< T >::i(), Triplet< T >::j(), SparseMatrix< T, ULI >::m(), SparseMatrix< T, ULI >::n(), SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, ICRS< T, _i_value >::r_ind, ICRS< T, _i_value >::r_start, Triplet< T >::value, and SparseMatrix< T, ULI >::zero_element.
Referenced by ICRS< T, _i_value >::ICRS().
|
inline |
Sets starting position of matrix multiplication.
(Useful for example when the input/output vectors will be shifted before passed on to this class' zax method.)
row_start | New row start location |
column_start | New column start location |
References ICRS< T, _i_value >::c_start, and ICRS< T, _i_value >::r_start.
|
inlinevirtual |
In-place z=Ax function.
Adapted from the master thesis of Joris Koster, Utrecht University.
pDataX | Pointer to array x to multiply by the current matrix (Ax). |
pDataZ | Pointer to result array. Must be pre-allocated and its elements set to zero for correct results. |
Implements SparseMatrix< T, ULI >.
References ICRS< T, _i_value >::c_ind, ICRS< T, _i_value >::c_start, ICRS< T, _i_value >::ds, SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, ICRS< T, _i_value >::r_ind, and ICRS< T, _i_value >::r_start.
|
inline |
|
inlinevirtual |
In-place z=xA function.
Adapted from the master thesis of Joris Koster, Utrecht University.
pDataX | Pointer to array x to multiply by the current matrix (Ax). |
pDataZ | Pointer to result array. Must be pre-allocated and its elements set to zero for correct results. |
Implements SparseMatrix< T, ULI >.
References ICRS< T, _i_value >::c_ind, ICRS< T, _i_value >::c_start, ICRS< T, _i_value >::ds, SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, ICRS< T, _i_value >::r_ind, and ICRS< T, _i_value >::r_start.
|
inline |
|
protected |
Remembers the number of bytes allocated.
Referenced by ICRS< T, _i_value >::bytesUsed(), ICRS< T, _i_value >::ICRS(), and ICRS< T, _i_value >::load().
|
protected |
Array containing the column jumps.
Referenced by ICRS< T, _i_value >::ICRS(), ICRS< T, _i_value >::load(), ICRS< T, _i_value >::zax(), ICRS< T, _i_value >::ZaX(), ICRS< T, _i_value >::zxa(), ICRS< T, _i_value >::ZXa(), and ICRS< T, _i_value >::~ICRS().
|
protected |
Array containing the actual nnz non-zeros.
Referenced by ICRS< T, _i_value >::ICRS(), ICRS< T, _i_value >::load(), ICRS< T, _i_value >::zax(), ICRS< T, _i_value >::ZaX(), ICRS< T, _i_value >::zxa(), ICRS< T, _i_value >::ZXa(), and ICRS< T, _i_value >::~ICRS().
|
static |
|
protected |
Array containing the row jumps.
Referenced by ICRS< T, _i_value >::ICRS(), ICRS< T, _i_value >::load(), ICRS< T, _i_value >::zax(), ICRS< T, _i_value >::ZaX(), ICRS< T, _i_value >::zxa(), ICRS< T, _i_value >::ZXa(), and ICRS< T, _i_value >::~ICRS().