User`s guide

5 Math with Codistributed Arrays
5-14
11 12 13 | 14 15 16 | 17 18 | 19 20
21 22 23 | 24 25 26 | 27 28 | 29 30
31 32 33 | 34 35 36 | 37 38 | 39 40
41 42 43 | 44 45 46 | 47 48 | 49 50
| | |
spmd, size(getLocalPart(D)), end
Lab 1:
4 3
Lab 2:
4 3
Lab 3:
4 2
Lab 4:
4 2
Restore the undistributed segments to the full array form by gathering the segments:
spmd, X = gather(D), end
X =
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
spmd, size(X), end
4 10
Indexing into a Codistributed Array
While indexing into a nondistributed array is fairly straightforward, codistributed arrays
require additional considerations. Each dimension of a nondistributed array is indexed
within a range of 1 to the final subscript, which is represented in MATLAB by the end
keyword. The length of any dimension can be easily determined using either the size or
length function.
With codistributed arrays, these values are not so easily obtained. For example, the
second segment of an array (that which resides in the workspace of worker 2) has a
starting index that depends on the array distribution. For a 200-by-1000 array with a
default distribution by columns over four workers, the starting index on worker 2 is 251.
For a 1000-by-200 array also distributed by columns, that same index would be 51. As for
the ending index, this is not given by using the end keyword, as end in this case refers