Let’s say I have 5 vectors A, B, C, D, E and I build a sparse matrix as follows:
M = spdiagm(0 => A, -1 => B, 1 => C, -10 => D, 10 => E)
So, as you see, all the nonzero entries are on the five diagonals. (So, the number of nonzero entries is fixed.) In my actual usage, the entries in vectors A, B, C are updated repetitively in a loop. Every time the vectors are updated, I need the M matrix to be updated as well. Currently, I just use spdiagm() to generate a new matrix repetitively in the loop. Since the matrix could be quite large sometimes, I thought it would be much more efficient if there is a way to update the nonzero entries of M in-place, without creating a new matrix every time. Is there such a way to update the entries of the sparse matrix without creating a new one? Thanks!