|
HDK
|
#include <UT_SparseMatrix.h>
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. More... | |
| int64 | getIdealMemoryUsage () const |
| void | reserve (int numcells) |
| void | shrinkToFit () |
| Shrinks the array to exactly fit the number of cells present. More... | |
| void | init (int rows, int cols) |
| void | zero () |
| bool | shouldMultiThread () const |
| bool | addToElement (int row, int col, T value) |
| int | findCellFromRow (int row) const |
| void | multVec (const UT_VectorT< T > &v, UT_VectorT< T > &result) const |
| void | subtractMultVec (const UT_VectorT< T > &v, UT_VectorT< T > &result) const |
| Do result = result - (M * v) More... | |
| void | subtractMultVecNoThread (const UT_VectorT< T > &v, UT_VectorT< T > &result) const |
| 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 | getSmallSquareSubMatrix (T submatrix[], const exint indices[], const int num_indices) const |
| template<typename Visitor > | |
| void | accept (Visitor &visitor) const |
| void | clearRowsAndColumns (const UT_BitArray &toclear) |
| 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, const UT_SparseMatrixT< T, IsPaged > *GT, bool(*callback_func)(void *)=0, void *callback_data=0, T tol2=1e-5, int max_iters=-1) const |
| void | transposePartial (const UT_JobInfo &info) |
| Transposes this matrix. More... | |
| void | transposeCompiled (const UT_SparseMatrixT< T, IsPaged > &src) |
| void | negatePartial (const UT_JobInfo &info) |
| *this = -*this. More... | |
| 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 (std::ostream &os) const |
| void | printSparse (std::ostream &os) const |
| void | printSparseMatlab (std::ostream &os, const UT_String &varname) const |
| void | save (std::ostream &os) const |
| void | load (UT_IStream &is) |
| void | compile () const |
| bool | isCompiled () const |
| bool | isStillSorted () const |
| bool | hasNan () const |
| void | testForNan () const |
Friends | |
| class | UT_SparseMatrixRowT< T > |
Definition at line 38 of file UT_SparseMatrix.h.
| UT_SparseMatrixT< T, IsPaged >::UT_SparseMatrixT | ( | ) |
| UT_SparseMatrixT< T, IsPaged >::UT_SparseMatrixT | ( | int | rows, |
| int | cols | ||
| ) |
| UT_SparseMatrixT< T, IsPaged >::UT_SparseMatrixT | ( | const UT_SparseMatrixT< T, IsPaged > & | m | ) |
| UT_SparseMatrixT< T, IsPaged >::~UT_SparseMatrixT | ( | ) |
|
inline |
Definition at line 219 of file UT_SparseMatrix.h.
| bool UT_SparseMatrixT< T, IsPaged >::addToElement | ( | int | row, |
| int | col, | ||
| T | value | ||
| ) |
| 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.
| void UT_SparseMatrixT< T, IsPaged >::clearRowsAndColumns | ( | const UT_BitArray & | toclear | ) |
Clear the rows and columns specified by the given bit field to a row from the identity matrix
| 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 +=.
| 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).
| void UT_SparseMatrixT< T, IsPaged >::extractNondiagonal | ( | UT_SparseMatrixT< T, IsPaged > & | out | ) | const |
Extract everything but the diagonal: out(i, j) = 0, if i == j,
| 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).
| 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.
| int UT_SparseMatrixT< T, IsPaged >::findCellFromRow | ( | int | row | ) | const |
| int64 UT_SparseMatrixT< T, IsPaged >::getIdealMemoryUsage | ( | ) | const |
| int64 UT_SparseMatrixT< T, IsPaged >::getMemoryUsage | ( | ) | const |
Return the amount of memory used by this array.
|
inline |
Definition at line 133 of file UT_SparseMatrix.h.
|
inline |
Definition at line 132 of file UT_SparseMatrix.h.
| void UT_SparseMatrixT< T, IsPaged >::getSmallSquareSubMatrix | ( | T | submatrix[], |
| const exint | indices[], | ||
| const int | num_indices | ||
| ) | const |
| bool UT_SparseMatrixT< T, IsPaged >::hasNan | ( | ) | const |
| int UT_SparseMatrixT< T, IsPaged >::incompleteCholeskyFactorization | ( | T | 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)
| void UT_SparseMatrixT< T, IsPaged >::init | ( | int | rows, |
| int | cols | ||
| ) |
|
inline |
Definition at line 328 of file UT_SparseMatrix.h.
|
inline |
Definition at line 329 of file UT_SparseMatrix.h.
| void UT_SparseMatrixT< T, IsPaged >::load | ( | UT_IStream & | is | ) |
| int UT_SparseMatrixT< T, IsPaged >::modifiedIncompleteCholesky | ( | T | tau = 0.97, |
| T | mindiagratio = 0.25, |
||
| T | 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.
|
inline |
Definition at line 169 of file UT_SparseMatrix.h.
| void UT_SparseMatrixT< T, IsPaged >::negatePartial | ( | const UT_JobInfo & | info | ) |
*this = -*this.
| UT_SparseMatrixT<T, IsPaged>& UT_SparseMatrixT< T, IsPaged >::operator*= | ( | T | scalar | ) |
| UT_SparseMatrixT<T, IsPaged>& UT_SparseMatrixT< T, IsPaged >::operator+= | ( | const UT_SparseMatrixT< T, IsPaged > & | m | ) |
| UT_SparseMatrixT<T, IsPaged>& UT_SparseMatrixT< T, IsPaged >::operator= | ( | const UT_SparseMatrixT< T, IsPaged > & | m | ) |
| void UT_SparseMatrixT< T, IsPaged >::printFull | ( | std::ostream & | os | ) | const |
| void UT_SparseMatrixT< T, IsPaged >::printSparse | ( | std::ostream & | os | ) | const |
| void UT_SparseMatrixT< T, IsPaged >::printSparseMatlab | ( | std::ostream & | os, |
| const UT_String & | varname | ||
| ) | const |
| void UT_SparseMatrixT< T, IsPaged >::reserve | ( | int | numcells | ) |
Ensures at least this number of cells are available, useful if you can predict your size.
| void UT_SparseMatrixT< T, IsPaged >::save | ( | std::ostream & | os | ) | const |
|
inline |
Definition at line 154 of file UT_SparseMatrix.h.
| void UT_SparseMatrixT< T, IsPaged >::shrinkToFit | ( | ) |
Shrinks the array to exactly fit the number of cells present.
| bool UT_SparseMatrixT< T, IsPaged >::solveConjugateGradient | ( | UT_VectorT< T > & | x, |
| const UT_VectorT< T > & | b, | ||
| const UT_SparseMatrixT< T, IsPaged > * | GT, | ||
| bool(*)(void *) | callback_func = 0, |
||
| void * | callback_data = 0, |
||
| T | tol2 = 1e-5, |
||
| int | max_iters = -1 |
||
| ) | const |
| int UT_SparseMatrixT< T, IsPaged >::solveLowerTriangular | ( | UT_VectorT< T > & | x, |
| const UT_VectorT< T > & | b, | ||
| T | 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.
| int UT_SparseMatrixT< T, IsPaged >::solveLowerTriangularTransposeNegate | ( | UT_VectorT< T > & | x, |
| const UT_VectorT< T > & | b, | ||
| T | tol = 1e-5 |
||
| ) | const |
Given an upper triangular matrix, solves the lower triangular transposed of it and negates the result.
| int UT_SparseMatrixT< T, IsPaged >::solveUpperTriangular | ( | UT_VectorT< T > & | x, |
| const UT_VectorT< T > & | b, | ||
| T | tol = 1e-5 |
||
| ) | const |
|
inline |
Do result = result - (M * v)
Definition at line 176 of file UT_SparseMatrix.h.
|
inline |
Definition at line 181 of file UT_SparseMatrix.h.
| void UT_SparseMatrixT< T, IsPaged >::testForNan | ( | ) | const |
| 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.
| void UT_SparseMatrixT< T, IsPaged >::transposeMultVec | ( | const UT_VectorT< T > & | v, |
| UT_VectorT< T > & | result | ||
| ) | const |
| void UT_SparseMatrixT< T, IsPaged >::transposePartial | ( | const UT_JobInfo & | info | ) |
Transposes this matrix.
| void UT_SparseMatrixT< T, IsPaged >::zero | ( | ) |
|
friend |
Definition at line 376 of file UT_SparseMatrix.h.