Allocate space for sparse distributed matrix
SD = distributed.spalloc(M,N,nzmax)
SD = distributed.spalloc(M,N,nzmax)
creates
an M
-by-N
all-zero sparse distributed
matrix with room to hold nzmax
nonzeros.
Allocate space for a 1000-by-1000 sparse distributed matrix with room for up to 2000 nonzero elements, then define several elements:
N = 1000; SD = distributed.spalloc(N,N,2*N); for ii=1:N-1 SD(ii,ii:ii+1) = [ii ii]; end