-
Notifications
You must be signed in to change notification settings - Fork 10
Description
RandBLAS' example for truncated QRCP of sparse matrices employs power iteration
RandBLAS/examples/sparse-low-rank-approx/qrcp_matrixmarket.cc
Lines 177 to 200 in 71b1b9d
int lu_row_stabilize(int64_t m, int64_t n, T* mat, int64_t* piv_work) { | |
randblas_require(m < n); | |
for (int64_t i = 0; i < m; ++i) | |
piv_work[i] = 0; | |
lapack::getrf(m, n, mat, m, piv_work); | |
// above: the permutation applied to the rows of mat doesn't matter in our context. | |
// below: Need to zero-out the strict lower triangle of mat and scale each row. | |
T tol = std::numeric_limits<T>::epsilon()*10; | |
bool nonzero_diag_U = true; | |
for (int64_t j = 0; (j < m-1) & nonzero_diag_U; ++j) { | |
nonzero_diag_U = abs(mat[j + j*m]) > tol; | |
for (int64_t i = j + 1; i < m; ++i) { | |
mat[i + j*m] = 0.0; | |
} | |
} | |
if (!nonzero_diag_U) { | |
throw std::runtime_error("LU stabilization failed. Matrix has been overwritten, so we cannot recover."); | |
} | |
for (int64_t i = 0; i < m; ++i) { | |
T scale = 1.0 / mat[i + i*m]; | |
blas::scal(n, scale, mat + i, m); | |
} | |
return 0; | |
} |
The method starts by decomposing
A proper way of doing LU-based co-range stabilization is to decompose