UT_SparseMatrixT< T, IsPaged > Class Template Reference

#include <UT_SparseMatrix.h>

List of all members.

Classes

class  ut_4MatrixCell
class  ut_CellIterator
class  ut_MatrixCell

Public Member Functions

 UT_SparseMatrixT ()
 UT_SparseMatrixT (int rows, int cols)
 UT_SparseMatrixT (const UT_SparseMatrixT< T, IsPaged > &m)
 ~UT_SparseMatrixT ()
int getNumRows () const
int getNumCols () const
int64 getMemoryUsage () const
 Return the amount of memory used by this array.
int64 getIdealMemoryUsage () const
void reserve (int numcells)
void shrinkToFit ()
 Shrinks the array to exactly fit the number of cells present.
void init (int rows, int cols)
void zero ()
bool shouldMultiThread () const
bool addToElement (int row, int col, T value)
int findCellFromRow (int row) const
 THREADED_METHOD2_CONST (UT_SparseMatrixT, shouldMultiThread(), multVec, const UT_VectorT< T > &, v, UT_VectorT< T > &, result) void multVecPartial(const UT_VectorT< T > &v
 THREADED_METHOD2_CONST (UT_SparseMatrixT, shouldMultiThread(), subtractMultVec, const UT_VectorT< T > &, v, UT_VectorT< T > &, result) void subtractMultVecPartial(const UT_VectorT< T > &v
 Do result = result - (M * v).
void transposeMultVec (const UT_VectorT< T > &v, UT_VectorT< T > &result) const
void allColNorm2 (UT_VectorT< T > &result) const
void extractSubMatrix (UT_SparseMatrixT< T, IsPaged > &out, int rowstart, int rowend, int colstart, int colend) const
void extractSubMatrixUncompiled (UT_SparseMatrixT< T, IsPaged > &out, int rowstart, int rowend, int colstart, int colend) const
void extractDiagonal (UT_VectorT< T > &out, int idx=0) const
void extractNondiagonal (UT_SparseMatrixT< T, IsPaged > &out) const
int incompleteCholeskyFactorization (T tol=1e-5)
int modifiedIncompleteCholesky (T tau=0.97, T mindiagratio=0.25, T tol=1e-5)
int solveLowerTriangular (UT_VectorT< T > &x, const UT_VectorT< T > &b, T tol=1e-5) const
int solveUpperTriangular (UT_VectorT< T > &x, const UT_VectorT< T > &b, T tol=1e-5) const
int solveLowerTriangularTransposeNegate (UT_VectorT< T > &x, const UT_VectorT< T > &b, T tol=1e-5) const
bool solveConjugateGradient (UT_VectorT< T > &x, const UT_VectorT< T > &b, bool(*callback_func)(void *)=0, void *callback_data=0, T tol=1e-5, int max_iters=-1) const
 THREADED_METHOD (UT_SparseMatrixT, shouldMultiThread(), transpose) void transposePartial(const UT_JobInfo &info)
 Transposes this matrix.
void transposeCompiled (const UT_SparseMatrixT< T, IsPaged > &src)
 THREADED_METHOD (UT_SparseMatrixT, shouldMultiThread(), negate) void negatePartial(const UT_JobInfo &info)
 *this = -*this.
UT_SparseMatrixT< T, IsPaged > & operator= (const UT_SparseMatrixT< T, IsPaged > &m)
UT_SparseMatrixT< T, IsPaged > & operator*= (T scalar)
UT_SparseMatrixT< T, IsPaged > & operator+= (const UT_SparseMatrixT< T, IsPaged > &m)
void printFull (ostream &os) const
void printSparse (ostream &os) const
void save (ostream &os) const
void load (UT_IStream &is)
void compile () const
bool isCompiled () const
bool isStillSorted () const

Public Attributes

UT_VectorT< T > & result
UT_VectorT< T > const
UT_JobInfo &info 
const

Friends

class UT_SparseMatrixRowT< T >


Detailed Description

template<typename T, bool IsPaged>
class UT_SparseMatrixT< T, IsPaged >

Definition at line 42 of file UT_SparseMatrix.h.


Constructor & Destructor Documentation

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::UT_SparseMatrixT (  ) 

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::UT_SparseMatrixT ( int  rows,
int  cols 
)

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::UT_SparseMatrixT ( const UT_SparseMatrixT< T, IsPaged > &  m  ) 

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::~UT_SparseMatrixT (  ) 


Member Function Documentation

template<typename T, bool IsPaged>
bool UT_SparseMatrixT< T, IsPaged >::addToElement ( int  row,
int  col,
value 
)

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::allColNorm2 ( UT_VectorT< T > &  result  )  const

Square of L2-norm of all columns Use to form the diagonal part of A^tA of an overdetermined system A. Needed for both Jacobi and Gauss-Seidel iterations.

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::compile (  )  const

Reorders the cell array to be sorted by row than column. Consolidates any duplicate entries by adding them together. Culls any zero entries. compile will be a no-op if the matrix's structure has not changed since the last invocation. While compilation is expensive, it also performs the collapse/cull operation, so you may want to invoke it explicitly if you are repeatedly gathering similar matrices, say with +=.

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::extractDiagonal ( UT_VectorT< T > &  out,
int  idx = 0 
) const

Extract the diagonal vector from a matrix. This does not require the matrix to be compiled, nor does it try to compile it. For entries (i, j), this method will extract the entries where (i-j == idx).

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::extractNondiagonal ( UT_SparseMatrixT< T, IsPaged > &  out  )  const

Extract everything but the diagonal: out(i, j) = 0, if i == j,

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::extractSubMatrix ( UT_SparseMatrixT< T, IsPaged > &  out,
int  rowstart,
int  rowend,
int  colstart,
int  colend 
) const

Initializes out to a matrix where the (i,j) elements are (rowstart+i, colstart+j) elements of this. The rowend and colend represent the exclusive end - [rowstart,rowend) will be extracted for numrows = rowend - rowstart This function will compile *this, if it wasn't before the call. The resulting matrix will be compiled (by construction).

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::extractSubMatrixUncompiled ( UT_SparseMatrixT< T, IsPaged > &  out,
int  rowstart,
int  rowend,
int  colstart,
int  colend 
) const

Extract submatrix without compiling *this. The resulting submatrix won't be compiled either.

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::findCellFromRow ( int  row  )  const

template<typename T, bool IsPaged>
int64 UT_SparseMatrixT< T, IsPaged >::getIdealMemoryUsage (  )  const

template<typename T, bool IsPaged>
int64 UT_SparseMatrixT< T, IsPaged >::getMemoryUsage (  )  const

Return the amount of memory used by this array.

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::getNumCols (  )  const [inline]

Definition at line 129 of file UT_SparseMatrix.h.

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::getNumRows (  )  const [inline]

Definition at line 128 of file UT_SparseMatrix.h.

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::incompleteCholeskyFactorization ( tol = 1e-5  ) 

Incomplete Cholesky Factorization. Does a Cholesky Factorization but does not make any elements non-zero The result of this operation is an UPPER triangular matrix G such that A = Gt G. The input must be a symmetric matrix. Note that this factorization is not always stable. Returns 0 on success, -1 if semi-definite (diagonal contained zeros within the given tolerance) and -2 if not positive definite (diagonal contained negative numbers)

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::init ( int  rows,
int  cols 
)

template<typename T, bool IsPaged>
bool UT_SparseMatrixT< T, IsPaged >::isCompiled (  )  const [inline]

Definition at line 297 of file UT_SparseMatrix.h.

template<typename T, bool IsPaged>
bool UT_SparseMatrixT< T, IsPaged >::isStillSorted (  )  const [inline]

Definition at line 298 of file UT_SparseMatrix.h.

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::load ( UT_IStream is  ) 

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::modifiedIncompleteCholesky ( tau = 0.97,
mindiagratio = 0.25,
tol = 1e-5 
)

Modified Incomplete Cholesky Same as incomplte cholesky, except attempt to account for the discarded entries by adjusting the diagonal. tau is a tuning constant.

template<typename T, bool IsPaged>
UT_SparseMatrixT<T, IsPaged>& UT_SparseMatrixT< T, IsPaged >::operator*= ( scalar  ) 

template<typename T, bool IsPaged>
UT_SparseMatrixT<T, IsPaged>& UT_SparseMatrixT< T, IsPaged >::operator+= ( const UT_SparseMatrixT< T, IsPaged > &  m  ) 

template<typename T, bool IsPaged>
UT_SparseMatrixT<T, IsPaged>& UT_SparseMatrixT< T, IsPaged >::operator= ( const UT_SparseMatrixT< T, IsPaged > &  m  ) 

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::printFull ( ostream &  os  )  const

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::printSparse ( ostream &  os  )  const

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::reserve ( int  numcells  ) 

Ensures at least this number of cells are available, useful if you can predict your size.

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::save ( ostream &  os  )  const

template<typename T, bool IsPaged>
bool UT_SparseMatrixT< T, IsPaged >::shouldMultiThread (  )  const [inline]

Definition at line 150 of file UT_SparseMatrix.h.

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::shrinkToFit (  ) 

Shrinks the array to exactly fit the number of cells present.

template<typename T, bool IsPaged>
bool UT_SparseMatrixT< T, IsPaged >::solveConjugateGradient ( UT_VectorT< T > &  x,
const UT_VectorT< T > &  b,
bool(*)(void *)  callback_func = 0,
void *  callback_data = 0,
tol = 1e-5,
int  max_iters = -1 
) const

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::solveLowerTriangular ( UT_VectorT< T > &  x,
const UT_VectorT< T > &  b,
tol = 1e-5 
) const

Assumes this is a lower triangular matrix. Solves the equation A x = b If the diagonal of A is zero within tolerance, the corresponding x coordinate is zero. Returned is the number of artifical zeros places into x. 0 means the solution encountered no singularities, 10 would mean 10 singularities.

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::solveLowerTriangularTransposeNegate ( UT_VectorT< T > &  x,
const UT_VectorT< T > &  b,
tol = 1e-5 
) const

Given an upper triangular matrix, solves the lower triangular transposed of it and negates the result.

template<typename T, bool IsPaged>
int UT_SparseMatrixT< T, IsPaged >::solveUpperTriangular ( UT_VectorT< T > &  x,
const UT_VectorT< T > &  b,
tol = 1e-5 
) const

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::THREADED_METHOD ( UT_SparseMatrixT< T, IsPaged >  ,
shouldMultiThread()  ,
negate   
) const

*this = -*this.

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::THREADED_METHOD ( UT_SparseMatrixT< T, IsPaged >  ,
shouldMultiThread()  ,
transpose   
) const

Transposes this matrix.

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::THREADED_METHOD2_CONST ( UT_SparseMatrixT< T, IsPaged >  ,
shouldMultiThread()  ,
subtractMultVec  ,
const UT_VectorT< T > &  ,
v  ,
UT_VectorT< T > &  ,
result   
) const

Do result = result - (M * v).

template<typename T, bool IsPaged>
UT_SparseMatrixT< T, IsPaged >::THREADED_METHOD2_CONST ( UT_SparseMatrixT< T, IsPaged >  ,
shouldMultiThread()  ,
multVec  ,
const UT_VectorT< T > &  ,
v  ,
UT_VectorT< T > &  ,
result   
) const

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::transposeCompiled ( const UT_SparseMatrixT< T, IsPaged > &  src  ) 

Makes this a transposed copy of source. By not working in place we can avoid a sort if the source is compiled. If source is not compiled, we compile it.

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::transposeMultVec ( const UT_VectorT< T > &  v,
UT_VectorT< T > &  result 
) const

template<typename T, bool IsPaged>
void UT_SparseMatrixT< T, IsPaged >::zero (  ) 


Friends And Related Function Documentation

template<typename T, bool IsPaged>
friend class UT_SparseMatrixRowT< T > [friend]

Definition at line 330 of file UT_SparseMatrix.h.


Member Data Documentation

template<typename T, bool IsPaged>
UT_VectorT< T > const UT_JobInfo &info UT_SparseMatrixT< T, IsPaged >::const

Definition at line 172 of file UT_SparseMatrix.h.

template<typename T, bool IsPaged>
UT_VectorT< T > & UT_SparseMatrixT< T, IsPaged >::result

Definition at line 172 of file UT_SparseMatrix.h.


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

Generated on Fri May 25 00:10:55 2012 for HDK by  doxygen 1.5.9