SparseLibrary  Version 1.6.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
SparseMatrix< T, IND > Class Template Referenceabstract

Interface common to all sparse matrix storage schemes. More...

#include <SparseMatrix.hpp>

Inheritance diagram for SparseMatrix< T, IND >:
Inheritance graph
[legend]
Collaboration diagram for SparseMatrix< T, IND >:
Collaboration graph
[legend]

Public Member Functions

 SparseMatrix ()
 Base constructor. More...
 
 SparseMatrix (const IND nzs, const IND nr, const IND nc, const T zero)
 Base constructor. More...
 
virtual ~SparseMatrix ()
 Base deconstructor. More...
 
virtual void load (std::vector< Triplet< T > > &input, const IND m, const IND n, const T zero)=0
 Function reading in from std::vector< Triplet< T > > format. 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 void getFirstIndexPair (IND &row, IND &col)=0
 Returns the first nonzero index, per reference. 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...
 
virtual size_t bytesUsed ()=0
 Function to query the amount of storage required by this sparse matrix. More...
 

Public Attributes

zero_element
 The element considered to be zero. More...
 

Protected Attributes

IND nor
 Number of rows. More...
 
IND noc
 Number of columns.
 
IND nnz
 Number of non-zeros. More...
 

Detailed Description

template<typename T, typename IND>
class SparseMatrix< T, IND >

Interface common to all sparse matrix storage schemes.

Constructor & Destructor Documentation

template<typename T, typename IND>
SparseMatrix< T, IND >::SparseMatrix ( )
inline

Base constructor.

template<typename T, typename IND>
SparseMatrix< T, IND >::SparseMatrix ( const IND  nzs,
const IND  nr,
const IND  nc,
const T  zero 
)
inline

Base constructor.

template<typename T, typename IND>
virtual SparseMatrix< T, IND >::~SparseMatrix ( )
inlinevirtual

Base deconstructor.

Member Function Documentation

template<typename T, typename IND>
virtual void SparseMatrix< T, IND >::getFirstIndexPair ( IND &  row,
IND &  col 
)
pure virtual
template<typename T, typename IND>
virtual void SparseMatrix< T, IND >::load ( std::vector< Triplet< T > > &  input,
const IND  m,
const IND  n,
const T  zero 
)
pure virtual
template<typename T, typename IND>
void SparseMatrix< T, IND >::loadFromFile ( const std::string  file,
const T  zero = 0 
)
inline

Function which loads a matrix from a matrix market file.

Parameters
fileFilename (including path) to the matrix market file.
zeroWhich element is to be considered zero.
template<typename T, typename IND>
virtual unsigned long int SparseMatrix< T, IND >::m ( )
inlinevirtual

Queries the number of rows this matrix contains.

Returns
The number of rows.

Implements Matrix< T >.

Reimplemented in CCSWrapper< T, SparseMatrixType, IND >.

Referenced by SparseMatrix< double, size_t >::loadFromFile().

template<typename T, typename IND>
virtual T* SparseMatrix< T, IND >::mv ( const T *  x)
inlinevirtual

Calculates and returns z=Ax.

The vectors x should have appropiately set length; this is not enforced. Memory leaks, segmentation faults, the works; one or more of these will occur if dimensions do not make sense. The return array is allocated to length equal to the number of rows in this function.

Warning The output vector is aligned to 64-byte boundaries. Free the assigned memory using _mm_free!

Parameters
xThe input (dense) x-vector.
Returns
The matrix-vector multiplication Ax, where A corresponds to the currently stored matrix.
See also
mv

Implements Matrix< T >.

Reimplemented in BetaHilbert< T >, RDBHilbert< T, MatrixType >, RDScheme< T, DS >, RDCSB< T >, McCRS< T >, MKLCRS< T >, and CCSWrapper< T, SparseMatrixType, IND >.

template<typename T, typename IND>
virtual unsigned long int SparseMatrix< T, IND >::n ( )
inlinevirtual

Queries the number of columns this matrix contains.

Returns
The number of columns.

Implements Matrix< T >.

Reimplemented in CCSWrapper< T, SparseMatrixType, IND >.

Referenced by SparseMatrix< double, size_t >::loadFromFile().

template<typename T, typename IND>
virtual unsigned long int SparseMatrix< T, IND >::nzs ( )
inlinevirtual

Queries the number of nonzeroes stored in this matrix.

Returns
The number of nonzeros.

Reimplemented from Matrix< T >.

Reimplemented in CCSWrapper< T, SparseMatrixType, IND >.

template<typename T, typename IND>
virtual void SparseMatrix< T, IND >::zax ( const T *__restrict__  x,
T *__restrict__  z 
)
pure virtual
template<typename T, typename IND>
virtual void SparseMatrix< T, IND >::zxa ( const T *__restrict__  x,
T *__restrict__  z 
)
pure virtual

Member Data Documentation

template<typename T, typename IND>
IND SparseMatrix< T, IND >::nnz
protected

Number of non-zeros.

Referenced by SparseMatrix< double, size_t >::nzs().

template<typename T, typename IND>
IND SparseMatrix< T, IND >::nor
protected
template<typename T, typename IND>
T SparseMatrix< T, IND >::zero_element

The element considered to be zero.

Referenced by SparseMatrix< double, size_t >::mv().


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