Public Member Functions

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

Diagonal sparse matrix format. More...

#include <spm.h>

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

List of all members.

Public Member Functions

 DiaSpM (int nrows, int ncols, int ndia)
 Creates a sparse matrix with the specified number of rows and (nonzero) diagonals.
void realloc (int nrows, int ncols, int ndia)
 Reallocates memory (if needed).
void setOffset (int dia, TI offset)
 Sets the offset of a diagonal.
void set (int row, int dia, TD v)
 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 * internalOffsetArray () const
 Gets the offset array.
TI * internalOffsetArray ()
 Gets the offset array.
int getNumDiagonals () const
 Gets the number of diagonals with nonzero elements.
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.
void toDenseMatrix (TD *mat) const
 Converts the sparse matrix to a dense matrix.

Detailed Description

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

Diagonal sparse matrix 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::DiaSpM< TD, TI >::DiaSpM ( int  nrows,
int  ncols,
int  ndia 
) [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
ndia the number of diagonals

Member Function Documentation

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

Gets the length of the internal data array.

Returns:
array length
template<class TD , class TI >
int gridripper::math::DiaSpM< 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::DiaSpM< TD, TI >::getNumDiagonals (  )  const [inline]

Gets the number of diagonals with nonzero elements.

Returns:
the number of diagonals
template<class TD , class TI >
void gridripper::math::DiaSpM< 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::DiaSpM< TD, TI >::internalArray (  )  [inline]

Gets the data array.

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

Gets the data array.

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

Gets the offset array.

Its length is returned by {

See also:
getNumDiagonals()}.
Returns:
the offset array
template<class TD , class TI >
const TI* gridripper::math::DiaSpM< TD, TI >::internalOffsetArray (  )  const [inline]

Gets the offset array.

Its length is returned by {

See also:
getNumDiagonals()}.
Returns:
the offset array
template<class TD , class TI >
void gridripper::math::DiaSpM< TD, TI >::realloc ( int  nrows,
int  ncols,
int  ndia 
) [inline]

Reallocates memory (if needed).

Parameters:
nrows new number of rows
ncols new number of columns
ndia new number of diagonals
template<class TD , class TI >
void gridripper::math::DiaSpM< TD, TI >::set ( int  row,
int  dia,
TD  v 
) [inline]

Sets a matrix element.

Parameters:
row the row index
dia the diagonal index
v the value
template<class TD , class TI >
void gridripper::math::DiaSpM< TD, TI >::setOffset ( int  dia,
TI  offset 
) [inline]

Sets the offset of a diagonal.

Parameters:
dia the diagonal index
offset the offset
template<class TD , class TI >
void gridripper::math::DiaSpM< 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: