HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SparseMatrixBuilderT< T > Class Template Reference

#include <UT_SparseMatrix.h>

Public Types

typedef UT_SparseMatrixCSRT< TSparseMatrixType
 

Public Member Functions

 UT_SparseMatrixBuilderT ()
 Construct an uninitialized sparse matrix builder. More...
 
 UT_SparseMatrixBuilderT (SparseMatrixType &matrix)
 Construct a sparse matrix builder for the given matrix. More...
 
void init (SparseMatrixType &matrix)
 Initializes the builder to start building the given matrix. More...
 
void setCapacity (exint capacity)
 
void startRow (exint row)
 
void addToColumn (exint col, T value)
 
void finish ()
 Completes the remaining rows and finalizes the matrix. More...
 

Detailed Description

template<typename T>
class UT_SparseMatrixBuilderT< T >

Simple helper class to construct a SparseMatrixCSRT. This operates on the matrix data in-place and is generally much more performant than constructing via triplets, but the builder has the limitation of only being able to add to rows sequentially; i.e. each call to startRow must start the construction of a row greater than the last, while addToColumn can be called with any column ordering.

  1. UT_SparseMatrixCSRD matrix(M, N);
  2. UT_SparseMatrixBuilderT builder(matrix);
  3. for (exint r = startRow; r < endRow; ++r)
  4. builder.startRow(r);
  5. for (any column)
  6. builder.addToColumn(column, value);
  7. builder.finish();

Definition at line 1035 of file UT_SparseMatrix.h.

Member Typedef Documentation

template<typename T >
typedef UT_SparseMatrixCSRT<T> UT_SparseMatrixBuilderT< T >::SparseMatrixType

Definition at line 1038 of file UT_SparseMatrix.h.

Constructor & Destructor Documentation

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

Construct an uninitialized sparse matrix builder.

Definition at line 1041 of file UT_SparseMatrix.h.

template<typename T >
UT_SparseMatrixBuilderT< T >::UT_SparseMatrixBuilderT ( SparseMatrixType matrix)
inline

Construct a sparse matrix builder for the given matrix.

Definition at line 1044 of file UT_SparseMatrix.h.

Member Function Documentation

template<typename T >
void UT_SparseMatrixBuilderT< T >::addToColumn ( exint  col,
T  value 
)

Adds the given value at the given column to the current row. If a cell is already present for the given column, the given value is added to it.

template<typename T >
void UT_SparseMatrixBuilderT< T >::finish ( )

Completes the remaining rows and finalizes the matrix.

template<typename T >
void UT_SparseMatrixBuilderT< T >::init ( SparseMatrixType matrix)

Initializes the builder to start building the given matrix.

template<typename T >
void UT_SparseMatrixBuilderT< T >::setCapacity ( exint  capacity)

Sets the minimum capacity of non-zero elements for the given matrix. This is used to preallocate memory for the matrix to avoid excessive reallocation as elements are added.

template<typename T >
void UT_SparseMatrixBuilderT< T >::startRow ( exint  row)

Advances the current row to the given row. The row must be greater than the current row.


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