SparseLibrary  Version 1.6.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
ICRS< T, _i_value > Class Template Reference

The incremental compressed row storage sparse matrix data structure. More...

#include <ICRS.hpp>

Inheritance diagram for ICRS< T, _i_value >:
Inheritance graph
[legend]
Collaboration diagram for ICRS< T, _i_value >:
Collaboration graph
[legend]

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 >
zero_element
 The element considered to be zero. More...
 

Detailed Description

template<typename T, typename _i_value = ULI>
class ICRS< T, _i_value >

The incremental compressed row storage sparse matrix data structure.

Constructor & Destructor Documentation

template<typename T, typename _i_value = ULI>
ICRS< T, _i_value >::ICRS ( )
inline

Base constructor.

template<typename T, typename _i_value = ULI>
ICRS< T, _i_value >::ICRS ( std::string  file,
zero = 0 
)
inline

Base constructor.

Will read in from Matrix Market file.

See also
SparseMatrix::SparseMatrix( file, zero )

References SparseMatrix< T, ULI >::loadFromFile().

template<typename T, typename _i_value = ULI>
ICRS< T, _i_value >::ICRS ( const ULI  number_of_nonzeros,
const ULI  number_of_rows,
const ULI  number_of_cols,
zero 
)
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).

Parameters
number_of_nonzerosThe number of non-zeros to be stored.
number_of_rowsThe number of rows of the matrix to be stored.
number_of_colsThe number of columns of the matrix to be stored.
zeroWhich 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.

template<typename T, typename _i_value = ULI>
ICRS< T, _i_value >::ICRS ( ICRS< T > &  toCopy)
inline
template<typename T, typename _i_value = ULI>
ICRS< T, _i_value >::ICRS ( std::vector< Triplet< T > > &  input,
const ULI  m,
const ULI  n,
const T  zero = 0 
)
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.

Parameters
inputThe input collection of triplets (i,j,val).
mThe number of rows of the input matrix.
nThe number of columns of the input matrix.
zeroWhich element is considered zero.

References ICRS< T, _i_value >::load().

template<typename T, typename _i_value = ULI>
ICRS< T, _i_value >::~ICRS ( )
inline

Member Function Documentation

template<typename T, typename _i_value = ULI>
virtual size_t ICRS< T, _i_value >::bytesUsed ( )
inlinevirtual

Function to query the amount of storage required by this sparse matrix.

Returns
The size of the sparse matrix in bytes.

Implements Matrix< T >.

References ICRS< T, _i_value >::bytes.

template<typename T, typename _i_value = ULI>
static int ICRS< T, _i_value >::compareTriplets ( const void *  left,
const void *  right 
)
inlinestatic

Comparison function used for sorting input data.

References Triplet< T >::i(), and Triplet< T >::j().

Referenced by ICRS< T, _i_value >::load().

template<typename T, typename _i_value = ULI>
virtual void ICRS< T, _i_value >::getFirstIndexPair ( ULI &  row,
ULI &  col 
)
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.

template<typename T, typename _i_value = ULI>
virtual void ICRS< T, _i_value >::load ( std::vector< Triplet< T > > &  input,
const ULI  m,
const ULI  n,
const T  zero 
)
inlinevirtual
template<typename T, typename _i_value = ULI>
void ICRS< T, _i_value >::setStartingPos ( const ULI  row_start,
const ULI  column_start 
)
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.)

Parameters
row_startNew row start location
column_startNew column start location

References ICRS< T, _i_value >::c_start, and ICRS< T, _i_value >::r_start.

template<typename T, typename _i_value = ULI>
virtual void ICRS< T, _i_value >::zax ( const T *__restrict__  pDataX,
T *__restrict__  pDataZ 
)
inlinevirtual

In-place z=Ax function.

Adapted from the master thesis of Joris Koster, Utrecht University.

Parameters
pDataXPointer to array x to multiply by the current matrix (Ax).
pDataZPointer 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.

template<typename T, typename _i_value = ULI>
template<size_t k>
void ICRS< T, _i_value >::ZaX ( const T *__restrict__ const *__restrict__ const  X,
T *__restrict__ const *__restrict__ const  Z 
)
inline
template<typename T, typename _i_value = ULI>
virtual void ICRS< T, _i_value >::zxa ( const T *__restrict__  pDataX,
T *__restrict__  pDataZ 
)
inlinevirtual

In-place z=xA function.

Adapted from the master thesis of Joris Koster, Utrecht University.

Parameters
pDataXPointer to array x to multiply by the current matrix (Ax).
pDataZPointer 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.

template<typename T, typename _i_value = ULI>
template<size_t k>
void ICRS< T, _i_value >::ZXa ( const T *__restrict__ const *__restrict__ const  X,
T *__restrict__ const *__restrict__ const  Z 
)
inline

Member Data Documentation

template<typename T, typename _i_value = ULI>
size_t ICRS< T, _i_value >::bytes
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().

template<typename T, typename _i_value = ULI>
_i_value* ICRS< T, _i_value >::c_ind
protected
template<typename T, typename _i_value = ULI>
T* ICRS< T, _i_value >::ds
protected
template<typename T, typename _i_value = ULI>
const size_t ICRS< T, _i_value >::fillIn = 0
static

Fill-in field for interoperability with vecBICRS.

Fill-in is always 0 for regular ICRS.

template<typename T, typename _i_value = ULI>
_i_value* ICRS< T, _i_value >::r_ind
protected

The documentation for this class was generated from the following file: