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

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

#include <ZZ_ICRS.hpp>

Inheritance diagram for ZZ_ICRS< T >:
Inheritance graph
[legend]
Collaboration diagram for ZZ_ICRS< T >:
Collaboration graph
[legend]

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

Detailed Description

template<typename T>
class ZZ_ICRS< T >

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

Constructor & Destructor Documentation

template<typename T>
ZZ_ICRS< T >::ZZ_ICRS ( )
inline

Base constructor.

template<typename T>
ZZ_ICRS< T >::ZZ_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, LI >::loadFromFile().

template<typename T>
ZZ_ICRS< T >::ZZ_ICRS ( const myULI  number_of_nonzeros,
const myULI  number_of_rows,
const myULI  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_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, SparseMatrix< T, LI >::nnz, and ZZ_ICRS< T >::r_ind.

template<typename T>
ZZ_ICRS< T >::ZZ_ICRS ( ZZ_ICRS< T > &  toCopy)
inline
template<typename T>
ZZ_ICRS< T >::ZZ_ICRS ( std::vector< Triplet< T > > &  input,
const myULI  m,
const myULI  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_ICRS< T >::load().

template<typename T>
ZZ_ICRS< T >::~ZZ_ICRS ( )
inline

Base deconstructor.

References ZZ_ICRS< T >::c_ind, ZZ_ICRS< T >::ds, and ZZ_ICRS< T >::r_ind.

Member Function Documentation

template<typename T>
virtual size_t ZZ_ICRS< T >::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 ZZ_ICRS< T >::jumps, and SparseMatrix< T, LI >::nnz.

template<typename T>
static bool ZZ_ICRS< T >::compareTriplets ( 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_ICRS< T >::load().

template<typename T>
virtual void ZZ_ICRS< T >::getFirstIndexPair ( myULI &  row,
myULI &  col 
)
inlinevirtual

Returns the first nonzero index, per reference.

Implements SparseMatrix< T, LI >.

References ZZ_ICRS< T >::c_ind, and ZZ_ICRS< T >::r_ind.

template<typename T>
virtual void ZZ_ICRS< T >::load ( std::vector< Triplet< T > > &  input,
const myULI  m,
const myULI  n,
const T  zero 
)
inlinevirtual
template<typename T>
virtual void ZZ_ICRS< T >::zax ( const T *__restrict__  pDataX,
T *__restrict__  pDataZ 
)
inlinevirtual

In-place z=Ax multiplication algorithm.

Parameters
pDataXThe vector x supplied for multiplication.
pDataZThe 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.

template<typename T>
virtual void ZZ_ICRS< T >::zxa ( const T *__restrict__  pDataX,
T *__restrict__  pDataZ 
)
inlinevirtual

In-place z=xA multiplication algorithm.

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

Member Data Documentation

template<typename T>
myULI* ZZ_ICRS< T >::c_ind
protected
template<typename T>
T* ZZ_ICRS< T >::ds
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().

template<typename T>
size_t ZZ_ICRS< T >::jumps
protected

The number of row jumps.

Referenced by ZZ_ICRS< T >::bytesUsed(), and ZZ_ICRS< T >::load().

template<typename T>
myULI* ZZ_ICRS< T >::r_ind
protected

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