Table Of Contents

Reshape Array (G Dataflow)

Version:
    Last Modified: March 15, 2017

    Changes the dimensions of an array according to a specified dimension size.

    This node reads the array data in memory from left to right, row by row and populates the reshaped array the same way. For example, if you pass a 2D array of 8 elements, 2 columns of {0,1,2,3}, to this node with two dimensions defined with sizes of 2 and 4, respectively, the node returns an array containing {{0,0,1,1}, {2,2,3,3}}.

    connector_pane_image
    datatype_icon

    array

    An n-dimensional array of any type.

    datatype_icon

    dimension size

    New size for a single dimension of array.

    The node creates an empty array if any dimension size is 0. You must have n dimension size inputs for n dimensions.

    Default: 0

    datatype_icon

    output array

    The array reshaped with dimension size.

    If the product of the dimension sizes is greater than the number of elements in the input array, the node pads the new array with the default of the data type of array. If the product of the dimension sizes is less than the number of elements in the input array, the node truncates the array.

    Modifying Array Data Using Dimension Size

    output array has one dimension for each dimension size input. You can resize the node to increase the number of dimension size parameters. Reshape Array pads or truncates array data if necessary to match dimension size parameters. For example, if you pass a 1D array with 9 elements {0, 1, 2, 3, 4, 5, 6, 7, 8} to this node with two dimensions defined with sizes of 2 and 3, respectively, the node returns a 2D array containing {{0, 1, 2}, {3, 4, 5}}. The node truncates the last three input elements because the output array has room for only six values. Similarly, if you pass the same 1D array to this node with two dimensions defined with sizes of 2 and 5, respectively, the node returns a 2D array containing {{0,1,2,3,4}, {5,6,7,8,0}}. The node pads the last element to match the values for dimension size.

    The following image illustrates this node's behavior for a variety of inputs:
    Output Panel Indicator Comments
    reshape to 1D Array Reshape Array populates reshape to 1D array left to right, row by row. Because the output array contains the same number of elements as the input array, no data is truncated or padded in the output array.
    reshape to 2D 2x4 Array Reshape Array populates reshape to 2x4 2D array left to right until it reaches the width limit of the array, row by row. Because the output array contains the same number of elements as the input array, no data is truncated or padded in the output array.

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics