User`s guide
sparse
11-285
Create a sparse codistributed array from vectors of indices and a distributed array of
element values:
r = [ 1 1 4 4 8];
c = [ 1 4 1 4 8];
v = [10 20 30 40 0];
V = distributed(v);
spmd
SC = sparse(r,c,V);
end
In this example, even though the fifth element of the value array v is 0, the size of the
result is an 8–by-8 matrix because of the corresponding maximum indices in r and c.
Matrix SC is considered codistributed when viewed inside an spmd block, and distributed
when viewed from the client workspace. To view a full version of the matrix, the full
function converts this distributed sparse array to a full distributed array:
S = full(SC)
10 0 0 20 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
30 0 0 40 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
See Also
sparse | distributed.spalloc | codistributed.spalloc