Contiguous and Noncontiguous Array Slices

LabVIEW 2018 Help


Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)


LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

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:

  • Array Subset—If LabVIEW represents the output from this function contiguously in memory, it creates a contiguous array slice.
  • Reverse 1D Array—If you wire an array to this function, it creates a noncontiguous array slice. If you wire an already reversed array slice to this function, it creates a contiguous array slice.
  • Split 1D Array—If you wire an array to this function, it creates a contiguous array slice. If you wire a noncontiguous array slice to this function, the resulting array slice is either contiguous or noncontiguous based on how LabVIEW represents the array slice in memory.
  • Transpose 2D Array—This function creates a noncontiguous array slice unless you wire an already transposed array to the function.
  • Cluster to Array—This function creates a contiguous array slice.
  • Index Array—This function creates a contiguous array slice unless you specify to index the array column-wise.
  • Decimate 1D Array—This function creates a noncontiguous array slice.

WAS THIS ARTICLE HELPFUL?

Not Helpful