randi
Create codistributed array of uniformly distributed random integers
Syntax
Description
creates an cR
= randi(r
,n
,codist
)n
-by-n
codistributed matrix
of uniformly distributed random integers in the range defined by
r
and uses codist
to specify the
distribution of the array values across the workers.
If
r
is a scalar, the function creates random integers in the range1
tor
.If
r
is a vector, the function creates random integers in the ranger(1)
tor(2)
.
Specify codist
as "codistributed"
to use the
default codistributor1d
distribution scheme or the distribution scheme
defined by a codistributor1d
or codistributor2dbc
object.
When you create the codistributed array in a communicating job or spmd
block, the function creates an array on each worker. If you create a codistributed array
outside of a communicating job or spmd
block, the array is stored only on
the worker or client that creates the codistributed array.
By default, the codistributed array has the underlying type double
.
creates an cR
= randi(r
,sz1,...,szN
,codist
)sz1
-by-...-by-szN
codistributed
array of uniformly distributed random integers between 1
to
r
. sz1,...,szN
indicates the size
of each dimension.
creates a codistributed array of uniformly distributed random integers with the
underlying type cR
= randi(___,datatype
,codist
)datatype
. For example,
randi([1,5],1,"int8","codistributed")
creates a
codistributed 8-bit random integer between 10
and
50
. You can use this syntax with any of the size
arguments in the previous syntaxes. You must specify codist
after the array size and data type arguments.
creates a codistributed array of uniformly distributed random integers without
using communication between workers.
cR
= randi(___,"noCommunication")
When you create very large arrays or your communicating job or spmd
block uses many workers, worker-worker communication can slow down array creation. Use this
syntax to improve the performance of your code by removing the time required for
worker-worker communication.
Tip
When you use this syntax, some error checking steps are skipped. Use this syntax
to improve the performance of your code after you prototype your code without
specifying "noCommunication"
.
You must specify "noCommunication"
after the size, data
type and codist
arguments.
uses the array cR
= randi(___,like=p
)p
to create a codistributed array of
uniformly distributed random integers. You can also specify
"noCommunication"
as part of the function call.
The returned array cR
has the same underlying type,
sparsity, and complexity (real or complex) as p
.
Examples
Input Arguments
Version History
Introduced in R2014a