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

The zig-zag compressed row storage sparse matrix data structure. More...

#include <ZZ_CRS.hpp>

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

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

Detailed Description

template<typename T, typename _i_value = LI>
class ZZ_CRS< T, _i_value >

The zig-zag compressed row storage sparse matrix data structure.

Constructor & Destructor Documentation

template<typename T, typename _i_value = LI>
ZZ_CRS< T, _i_value >::ZZ_CRS ( )
inline

Base constructor.

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

Base constructor.

Will read in from Matrix Market file.

See also
SparseMatrix::SparseMatrix( file, zero )

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

template<typename T, typename _i_value = LI>
ZZ_CRS< T, _i_value >::ZZ_CRS ( const long int  number_of_nonzeros,
const long int  number_of_rows,
const long int  number_of_cols,
zero 
)
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).

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

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

Parameters
inputThe input collection.
mTotal number of rows.
nTotal number of columns.
zeroWhich element is considered zero.

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

template<typename T, typename _i_value = LI>
ZZ_CRS< T, _i_value >::~ZZ_CRS ( )
inline

Member Function Documentation

template<typename T, typename _i_value = LI>
virtual size_t ZZ_CRS< 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 SparseMatrix< T, LI >::nnz, and SparseMatrix< T, LI >::nor.

template<typename T, typename _i_value = LI>
static bool ZZ_CRS< T, _i_value >::compareTripletsLTR ( const Triplet< T > *  one,
const Triplet< T > *  two 
)
inlinestaticprotected

Comparison function used for sorting input data.

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

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

template<typename T, typename _i_value = LI>
static bool ZZ_CRS< T, _i_value >::compareTripletsRTL ( const Triplet< T > *  one,
const Triplet< T > *  two 
)
inlinestaticprotected

Comparison function used for sorting input data.

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

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

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

template<typename T, typename _i_value = LI>
virtual void ZZ_CRS< T, _i_value >::load ( std::vector< Triplet< T > > &  input,
const LI  m,
const LI  n,
const T  zero 
)
inlinevirtual
template<typename T, typename _i_value = LI>
virtual void ZZ_CRS< T, _i_value >::zax ( const T *__restrict__  x,
T *__restrict  z 
)
inlinevirtual

In-place z=Ax multiplication algorithm.

Parameters
xThe vector x supplied for multiplication.
zThe 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.

template<typename T, typename _i_value = LI>
virtual void ZZ_CRS< T, _i_value >::zxa ( const T *  x,
T *  z 
)
inlinevirtual

In-place z=xA multiplication algorithm.

Parameters
xThe vector x supplied for left-multiplication.
zThe 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.

Member Data Documentation

template<typename T, typename _i_value = LI>
LI* ZZ_CRS< T, _i_value >::col_ind
protected
template<typename T, typename _i_value = LI>
T* ZZ_CRS< T, _i_value >::ds
protected
template<typename T, typename _i_value = LI>
LI* ZZ_CRS< T, _i_value >::row_start
protected

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