Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions copt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def fast_csr_vm(x, data, indptr, indices, d, idx):
return res


@njit(nogil=True)
@njit(parallel=True)
def fast_csr_mv(data, indptr, indices, x, idx):
"""
Returns the matrix vector product M[idx] * x. M is described
Expand All @@ -120,10 +120,13 @@ def fast_csr_mv(data, indptr, indices, x, idx):
"""

res = np.zeros(len(idx))
for i, row_idx in np.ndenumerate(idx):
for k, j in enumerate(range(indptr[row_idx], indptr[row_idx+1])):
for i in prange(len(idx)):
row_idx = idx[i]
res_i = 0.0
for j in range(indptr[row_idx], indptr[row_idx+1]):
j_idx = indices[j]
res[i] += x[j_idx] * data[j]
res_i += x[j_idx] * data[j]
res[i] = res_i
return res


Expand Down