Sparse matrix 700x slower than full

Setting coefficients of a sparse matrix is slow because it generally requires moving around all of the data after whatever coefficient you’ve set, which can be quite expensive. That’s why it’s generally recommended to build up a vectors of row indices, column indices, and values, and then call sparse(I, J, V) to build the sparse matrix all at once, ref: Sparse Arrays · The Julia Language

10 Likes