Created
September 25, 2018 21:37
-
-
Save chelseatroy/7a60db1691c7e85b47f9742879bd5454 to your computer and use it in GitHub Desktop.
implementation of csr_todense
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compute B += A for CSR matrix A, C-contiguous dense matrix B | |
* | |
* Input Arguments: | |
* I n_row - number of rows in A | |
* I n_col - number of columns in A | |
* I Ap[n_row+1] - row pointer | |
* I Aj[nnz(A)] - column indices | |
* T Ax[nnz(A)] - nonzero values | |
* T Bx[n_row*n_col] - dense matrix in row-major order | |
* | |
*/ | |
template <class I, class T> | |
void csr_todense(const I n_row, | |
const I n_col, | |
const I Ap[], | |
const I Aj[], | |
const T Ax[], | |
T Bx[]) | |
{ | |
T * Bx_row = Bx; | |
for(I i = 0; i < n_row; i++){ | |
for(I jj = Ap[i]; jj < Ap[i+1]; jj++){ | |
Bx_row[Aj[jj]] += Ax[jj]; | |
} | |
Bx_row += (npy_intp)n_col; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment