Skip to Main Content Skip to Search
Product Documentation

sparse - Create sparse distributed or codistributed matrix

Syntax

SD = sparse(FD)
SC = sparse(m, n, codist)
SC = sparse(m, n, codist, 'noCommunication')

Description

SD = sparse(FD) converts a full distributed or codistributed array FD to a sparse distributed or codistributed (respectively) array SD.

SC = sparse(m, n, codist) creates an m-by-n sparse codistributed array of underlying class double, distributed according to the scheme defined by the codistributor codist. For information on constructing codistributor objects, see the reference pages for codistributor1d and codistributor2dbc. This form of the syntax is most useful inside spmd, pmode, or a parallel job.

SC = sparse(m, n, codist, 'noCommunication') creates an m-by-n sparse codistributed array in the manner specified above, but does not perform any global communication for error checking when constructing the array. This form of the syntax is most useful inside spmd, pmode, or a parallel job.

Examples

With four labs,

spmd(4)
    C = sparse(1000, 1000, codistributor1d())
end

creates a 1000-by-1000 codistributed sparse double array C. C is distributed by its second dimension (columns), and each lab contains a 1000-by-250 local piece of C.

spmd(4)
    codist = codistributor1d(2, 1:numlabs)
    C = sparse(10, 10, codist);
end

creates a 10-by-10 codistributed sparse double array C, distributed by its columns. Each lab contains a 10-by-labindex local piece of C.

Convert a distributed array into a sparse distributed array:

R = distributed.rand(1000);
D = floor(2*R); % D also is distributed
SD = sparse(D); % SD is sparse distributed

See Also

codistributed.spalloc | distributed.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