Public Member Functions

gridripper::math::CsrSpM< TD, TI > Class Template Reference

Compressed sparse row format. More...

#include <spm.h>

Inheritance diagram for gridripper::math::CsrSpM< TD, TI >:
gridripper::math::SpM< TD >

List of all members.

Public Member Functions

 CsrSpM (int nrows, int ncols, int nonzero)
 Creates a sparse matrix with the specified number of rows and (nonzero) diagonals.
void realloc (int nrows, int ncols, int nonzero)
 Reallocates memory (if needed).
void setRowPtr (int row, TI p)
 Sets the data array index of a row.
void set (int row, int col, TD v, int i)
 Sets a matrix element.
const TD * internalArray () const
 Gets the data array.
TD * internalArray ()
 Gets the data array.
int arrayLength () const
 Gets the length of the internal data array.
const TI * internalRowPtrArray () const
 Gets the array containing the indices of the first nonzero row elements.
TI * internalRowPtrArray ()
 Gets the array containing the indices of the first nonzero row elements.
const TI * internalColumnIndexArray () const
 Gets the column indices array.
TI * internalColumnIndexArray ()
 Gets the column indices array.
int countNonzerosInRow (int row) const
 Gets the number of nonzeros in the specified row.
void gmv (TD *y, TD alpha, const TD *x, TD beta, const TD *b) const
 General matrix-vector operation.
int getNonzeroCount () const
 Gets the number of nonzero elements.
void toDenseMatrix (TD *mat) const
 Converts the sparse matrix to a dense matrix.

Detailed Description

template<class TD, class TI>
class gridripper::math::CsrSpM< TD, TI >

Compressed sparse row format.

See N. Bell and M. Garland, "Efficient Sparse Matrix-Vector Multiplication on CUDA", NVIDIA Technical Report NVR-2008-004.

Version:
07/03/2009
Since:
06/30/2009
Author:
Peter Csizmadia

Constructor & Destructor Documentation

template<class TD , class TI >
gridripper::math::CsrSpM< TD, TI >::CsrSpM ( int  nrows,
int  ncols,
int  nonzero 
) [inline]

Creates a sparse matrix with the specified number of rows and (nonzero) diagonals.

Parameters:
nrows the number of rows
ncols the number of columns
nonzero number of nonzero elements

Member Function Documentation

template<class TD , class TI >
int gridripper::math::CsrSpM< TD, TI >::arrayLength (  )  const [inline]

Gets the length of the internal data array.

Returns:
array length
template<class TD , class TI >
int gridripper::math::CsrSpM< TD, TI >::countNonzerosInRow ( int  row  )  const [inline, virtual]

Gets the number of nonzeros in the specified row.

Parameters:
row the row index
Returns:
the number of nonzeros

Implements gridripper::math::SpM< TD >.

template<class TD , class TI >
int gridripper::math::CsrSpM< TD, TI >::getNonzeroCount (  )  const [inline]

Gets the number of nonzero elements.

Returns:
the number of nonzero elements
template<class TD , class TI >
void gridripper::math::CsrSpM< TD, TI >::gmv ( TD *  y,
TD  alpha,
const TD *  x,
TD  beta,
const TD *  b 
) const [inline, virtual]

General matrix-vector operation.

Computes y = alpha*A*x + beta*b.

Parameters:
y the output vector
alpha scalar multiplier applied to A
x the x vector
beta scalar multiplier applied to b
b the b vector or NULL

Implements gridripper::math::SpM< TD >.

template<class TD , class TI >
TD* gridripper::math::CsrSpM< TD, TI >::internalArray (  )  [inline]

Gets the data array.

Returns:
the data array
template<class TD , class TI >
const TD* gridripper::math::CsrSpM< TD, TI >::internalArray (  )  const [inline]

Gets the data array.

Returns:
the data array
template<class TD , class TI >
const TI* gridripper::math::CsrSpM< TD, TI >::internalColumnIndexArray (  )  const [inline]

Gets the column indices array.

Returns:
the indices
template<class TD , class TI >
TI* gridripper::math::CsrSpM< TD, TI >::internalColumnIndexArray (  )  [inline]

Gets the column indices array.

Returns:
the indices
template<class TD , class TI >
TI* gridripper::math::CsrSpM< TD, TI >::internalRowPtrArray (  )  [inline]

Gets the array containing the indices of the first nonzero row elements.

Returns:
array of row pointers
template<class TD , class TI >
const TI* gridripper::math::CsrSpM< TD, TI >::internalRowPtrArray (  )  const [inline]

Gets the array containing the indices of the first nonzero row elements.

Returns:
array of row pointers
template<class TD , class TI >
void gridripper::math::CsrSpM< TD, TI >::realloc ( int  nrows,
int  ncols,
int  nonzero 
) [inline]

Reallocates memory (if needed).

Parameters:
nrows new number of rows
ncols new number of columns
nonzero maximum number of nonzero elements
template<class TD , class TI >
void gridripper::math::CsrSpM< TD, TI >::set ( int  row,
int  col,
TD  v,
int  i 
) [inline]

Sets a matrix element.

Parameters:
row the row index
col the column
v the value
i index
template<class TD , class TI >
void gridripper::math::CsrSpM< TD, TI >::setRowPtr ( int  row,
TI  p 
) [inline]

Sets the data array index of a row.

Parameters:
row the row index
p index of first nonzero element in the data array
template<class TD , class TI >
void gridripper::math::CsrSpM< TD, TI >::toDenseMatrix ( TD *  mat  )  const [inline, virtual]

Converts the sparse matrix to a dense matrix.

Parameters:
mat output array for the dense matrix

Implements gridripper::math::SpM< TD >.


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