iheartla / Iheartla.github.io

0 stars 0 forks source link

Accessing sparse matrix elements in python has poor performance #12

Open pressureless opened 3 years ago

pressureless commented 3 years ago

Create by @yig:

This I❤️LA code:

D_i,i = -sum_(l for l ≠ i) L_i,l

where

L ∈ ℝ^(n×n) sparse

produces Python code which accesses elements of L via L.tocsr()[i-1, l-1] in a loop. There should instead of an L = L.tocsr() outside the loop, since the CSR conversion would be slow (unless it's already in CSR format).