sprand - Create codistributed sparse array of uniformly distributed pseudo-random values

Syntax

D = sprand(m, n, density, dist)

Description

D = sprand(m, n, density, dist) creates an m-by-n sparse codistributed array with approximately density*m*n uniformly distributed nonzero double entries. D is distributed by dimension dim, where dim = distributionDimension(dist), and with partition PAR, where PAR = distributionPartition(dist). If dim is unspecified, D is distributed by its second dimension. If PAR is unspecified, D uses defaultPartition(n) as its partition. The easiest way to do this is to use a default codistributor where both dim and PAR are unspecified (dist = codistributor()) as input to sprandn.

Remarks

When you use sprand in a distributed or parallel job (including pmode), each worker or lab sets its random generator seed to a value that depends only on the lab index or task ID. Therefore, the array on each lab is unique for that job. However, if you repeat the job, you get the same random data.

Examples

With four labs,

D = sprand(1000, 1000, .001, codistributor())

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

D = sprand(10, 10, .1, codistributor('1d', 2, 1:numlabs))

creates a 10-by-10 codistributed double array D with approximately 10 nonzeros. D is distributed by its columns, and each lab contains a 10-by-labindex local piece of D.

See Also

sprand MATLAB function reference page

cell, eye, false, Inf, NaN, ones, rand, randn, sparse, speye, sprandn, true, zeros

  


 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS