Main Page | Class List | File List | Class Members

CS_CRS< T > Class Template Reference

The compressed row storage sparse matrix data structure. More...

#include <CS_CRS.hpp>

Collaboration diagram for CS_CRS< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CS_CRS (const ULI number_of_nonzeros, const ULI number_of_rows, const ULI number_of_cols, const T zero)
 Base constructor which only initialises the internal arrays.
 CS_CRS (CRS< T > &toCopy)
 Copy constructor.
 CS_CRS (CS_CRS< T > &toCopy)
 Copy constructor.
 CS_CRS (std::vector< Triplet< T > > input, unsigned long int currow, unsigned long int curcol, T &zero)
 Constructor which transforms a collection of input triplets to CRS format.
 CS_CRS (std::vector< Triplet< T > > input, T &zero)
 Constructor which transforms a collection of input triplets to CRS format.
T & random_access (ULI i, ULI j)
 Method which provides random matrix access to the stored sparse matrix.
T * zax (T *x_orig)
 Calculates and returns z=Ax.
 ~CS_CRS ()
 Base deconstructor.

Protected Member Functions

bool find (ULI col_index, ULI search_start, ULI search_end, ULI &ret)
 Helper function which finds a value with a given column index on a given subrange of indeces.

Static Protected Member Functions

int compareTriplets (const void *left, const void *right)
 Comparation function for 1D columnwise sort.

Protected Attributes

CS_ELEMENT< ULI > * nnz
 Number of non-zeros.
CS_ELEMENT< ULI > * nor
 Number of rows.
CS_ELEMENT< ULI > * noc
 Number of columns.
CS_ARRAY< ULI > * row_start
 Array keeping track of individual row starting indeces.
CS_ARRAY< T > * nzs
 Array containing the actual nnz non-zeros.
CS_ARRAY< ULI > * col_ind
 Array containing the column indeces corresponding to the elements in nzs.
CS_ELEMENT< T > * zero_element
 Which element is considered as zero.

Detailed Description

template<typename T>
class CS_CRS< T >

The compressed row storage sparse matrix data structure.


Constructor & Destructor Documentation

template<typename T>
CS_CRS< T >::CS_CRS const ULI  number_of_nonzeros,
const ULI  number_of_rows,
const ULI  number_of_cols,
const T  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_nonzeros The number of non-zeros of the matrix to be stored.
number_of_rows The number of rows of the matrix to be stored.
number_of_cols The number of columns of the matrix to be stored.
zero Which element is considered to be the zero element.

template<typename T>
CS_CRS< T >::CS_CRS CS_CRS< T > &  toCopy  )  [inline]
 

Copy constructor.

Parameters:
toCopy reference to the CS_CRS datastructure to copy.

template<typename T>
CS_CRS< T >::CS_CRS std::vector< Triplet< T > >  input,
unsigned long int  currow,
unsigned long int  curcol,
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:
input The input collection.
currow The number of rows of the input matrix.
curcol The number of columns of the input matrix.
zero Which element is considered zero.

template<typename T>
CS_CRS< T >::CS_CRS std::vector< Triplet< T > >  input,
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:
input The input collection.
zero Which element is considered zero.


Member Function Documentation

template<typename T>
int CS_CRS< T >::compareTriplets const void *  left,
const void *  right
[inline, static, protected]
 

Comparation function for 1D columnwise sort.

Parameters:
left The triplet at the left side of the comparation operator <
right The triplet at the right side of the comparation operator <
Returns:
-1 iff the column of left is less than that of right, 1 if it is larger, 0 if equal.

template<typename T>
bool CS_CRS< T >::find ULI  col_index,
ULI  search_start,
ULI  search_end,
ULI &  ret
[inline, protected]
 

Helper function which finds a value with a given column index on a given subrange of indeces.

Parameters:
col_index The given column index.
search_start The start index of the subrange (inclusive).
search_end The end index of the subrange (exlusive).
ret Reference to the variable where the return *index* is stored.
Returns:
Whether or not a non-zero value should be returned.

template<typename T>
T& CS_CRS< T >::random_access ULI  i,
ULI  j
[inline]
 

Method which provides random matrix access to the stored sparse matrix.

Parameters:
i Row index.
j Column index.
Returns:
Matrix valuei at (i,j).

template<typename T>
T* CS_CRS< T >::zax T *  x_orig  )  [inline]
 

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 a length equal to the number of rows in this function. Cache simulation is only performed on access to elements from A, x or z.

Parameters:
x_orig The input (dense) x-vector.
Returns:
The matrix-vector multiplication Ax, where A corresponds to the currently stored matrix.


The documentation for this class was generated from the following file:
Generated on Fri Aug 15 18:12:23 2008 for Run-timeCacheSimulator by  doxygen 1.3.9.1