There are two ways one can initialize a NXN sparse matrix, whose entries are to be read from one/multiple text files. Which one is faster ? I need the more efficient one, as N is large, typically 10^6.
- I could store the (x,y) indices in arrays
y, the entries in an array
K = sparse(x,y,value);
- I could declare
K = spzeros(N)
then read of the (i,j) coordinates and values v and insert them as
as they are being read.
I found no tips about this in Julia’s page on sparse arrays.