Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

partition

Lindsey Kuper edited this page Feb 12, 2015 · 3 revisions

Description

partition does the opposite of flatten: it creates a ParallelArray of n+1 dimensions from a ParallelArray of n dimensions. However, it is more general than flatten: while flatten collapses two dimensions into one, partition splits the outermost dimension of a ParallelArray into two or more dimensions, depending on the size argument passed to it.

Synopsis

myParallelArray.partition(size)

Arguments

  • size: the size of each element of the new dimension to be created. The number of elements in the outermost dimension of the ParallelArray on which partition is invoked should be divisible by size.

Returns

A freshly minted ParallelArray where the outermost dimension has been partitioned into multiple ParallelArrays with size elements each.

Examples

var pa = new ParallelArray([1, 2, 3, 4]);

// create a ParallelArray [[1, 2], [3, 4]], where [1, 2] and [3, 4]
// are themselves each ParallelArrays of length two
var partitionedArray = pa.partition(2);