Main Content

codistributed

Create codistributed array from replicated local data

Syntax

C = codistributed(X)
C = codistributed(X,codist)
C = codistributed(X,lab,codist)
C = codistributed(C1,codist)

Description

C = codistributed(X)distributes a replicated arrayXusing the default codistributor, creating acodistributedarrayCas a result.Xmust be a replicated array, that is, it must have the same value on all workers.size(C)is the same assize(X).

C = codistributed(X,codist)distributes a replicated arrayXusing the distribution scheme defined by codistributorcodist.Xmust be a replicated array, namely it must have the same value on all workers.size(C)is the same assize(X). For information on constructing codistributor objects, see the reference pages forcodistributor1dandcodistributor2dbc.

C = codistributed(X,lab,codist)distributes a local arrayXthat resides on the worker identified bylab, using the codistributorcodist. Local arrayXmust be defined on all workers, but only the value fromlabis used to constructC.size(C)is the same assize(X).

C = codistributed(C1,codist)accepts an arrayC1that is already codistributed, and redistributes it intoCaccording to the distribution scheme defined by the codistributorcodist. This is the same as callingC = redistribute(C1,codist). If the existing distribution scheme forC1is the same as that specified incodist, then the resultCis the same as the inputC1.

Examples

Create a 1000-by-1000 codistributed arrayC1using the default distribution scheme.

spmdN = 1000; X = magic(N);% Replicated on every workerC1 = codistributed (X);% Partitioned among the workersend

Create a 1000-by-1000 codistributed arrayC2, distributed by rows (over its first dimension).

spmdN = 1000; X = magic(N); C2 = codistributed(X,codistributor1d(1));end

Tips

gatheressentially performs the inverse ofcodistributed.