Contiguous and Noncontiguous Array Slices

To optimize performance, LabVIEW sometimes creates array slices from the arrays you wire to certain Array functions. An array slice is an array created from another array, and it contains some of the elements from the original array. LabVIEW expresses an array slice as a (sub)array in the Context Help window when you move the cursor over the wire for the resulting array. For example, (1-D (sub)array of) indicates that the function creates an array slice, while (1-D array of) indicates the resulting array contains all of the resulting elements.

Note  The Context Help window only differentiates between arrays and array slices if you allow debugging for the VI on the Execution page of the VI Properties dialog box.

If LabVIEW creates an array slice, it may create a contiguous array slice, which stores data adjacently, or a noncontiguous array slice, which stores data nonadjacently. If you wire an array slice to the Preallocated Read from Binary File function, you might need to know whether the array slice is contiguous or noncontiguous, because the function provides different levels of support that depend on the array you use.

Determining Whether LabVIEW Creates a Contiguous or Noncontiguous Array Slice

Array functions in LabVIEW access data in row-major order. If you arrange the elements of an array in row-major order, then LabVIEW represents that array in memory contiguously. LabVIEW represents the following 2D array in memory contiguously as a 1D line from 0 to 15:

0123
4567
891011
12131415

If you wire the previous array to the Index Array function and set the index (row) input to 0, LabVIEW may return an array or a contiguous array slice. The array slice is contiguous because LabVIEW represents the values in adjacent memory offsets 0, 1, 2, 3.

If you wire the previous array to the Index Array function and set the index (col) input to 0, LabVIEW may return an array or a noncontiguous array slice. The array slice is noncontiguous because LabVIEW represents the values in nonadjacent memory offsets 0, 4, 8, 12.

The following functions might return an array slice. If one of these functions returns an array slice, use the following guidelines to determine whether LabVIEW creates a contiguous or noncontiguous array slice: