Skip to Main Content Skip to Search
Product Documentation

codistributed.spalloc - Allocate space for sparse codistributed matrix

Syntax

SD = codistributed.spalloc(M, N, nzmax)
SD = spalloc(M, N, nzmax, codist)

Description

SD = codistributed.spalloc(M, N, nzmax) creates an M-by-N all-zero sparse codistributed matrix with room to hold nzmax nonzeros.

Optional arguments to codistributed.spalloc must be specified after the required arguments, and in the following order:

SD = spalloc(M, N, nzmax, codist) is the same as SD = codistributed.spalloc(M, N, nzmax, codist). You can also use the optional arguments with this syntax.

Examples

Allocate space for a 1000-by-1000 sparse codistributed matrix with room for up to 2000 nonzero elements. Use the default codistributor. Define several elements of the matrix.

spmd  % codistributed array created inside spmd statement
    N = 1000;
    SD = codistributed.spalloc(N, N, 2*N);
    for ii=1:N-1
      SD(ii,ii:ii+1) = [ii ii];
    end
end

See Also

distributed.spalloc | spalloc | sparse

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS