A high-performance general-purpose compute library

Generate a tiled array by repeating an array's contents along a specified dimension. More...

Functions

AFAPI array tile (const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
 C++ Interface to generate a tiled array. More...
 
AFAPI array tile (const array &in, const dim4 &dims)
 C++ Interface to generate a tiled array. More...
 
AFAPI af_err af_tile (af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
 C Interface to generate a tiled array. More...
 

Detailed Description

Generate a tiled array by repeating an array's contents along a specified dimension.

Creates copies of the input array and concatenates them with each other, such that the output array will have as many copies of the input array as the user specifies along each dimension. In this sense, the output array is a set of "tiles" where each copy of the input array, including the original, is a "tile".

Given below are some examples. The input array looks like this:

float hA[] = {0, 1, 2, 3, 4, 5};
array A(3, 2, hA);
// 0. 3.
// 1. 4.
// 2. 5.

Here, the input array is tiled along the first dimenson, 2 times:

array B = tile(A, 2, 1);
// 0. 3.
// 1. 4.
// 2. 5.
// 0. 3.
// 1. 4.
// 2. 5.

Here, the input is tiled along the second dimension, 3 times:

array C = tile(A, 1, 3);
// 0. 3. 0. 3. 0. 3.
// 1. 4. 1. 4. 1. 4.
// 2. 5. 2. 5. 2. 5.

Lastly, one can also tile along multiple dimensions simultaneously. Here, the input is tiled 2 times in the first dimension and 3 times in the second dimension:

array D = tile(A, 2, 3);
// 0. 3. 0. 3. 0. 3.
// 1. 4. 1. 4. 1. 4.
// 2. 5. 2. 5. 2. 5.
// 0. 3. 0. 3. 0. 3.
// 1. 4. 1. 4. 1. 4.
// 2. 5. 2. 5. 2. 5.

Function Documentation

◆ af_tile()

AFAPI af_err af_tile ( af_array out,
const af_array  in,
const unsigned  x,
const unsigned  y,
const unsigned  z,
const unsigned  w 
)

C Interface to generate a tiled array.

Note, x, y, z, and w include the original in the count.

Parameters
[out]outtiled array
[in]ininput array
[in]xnumber of tiles along the first dimension
[in]ynumber of tiles along the second dimension
[in]znumber of tiles along the third dimension
[in]wnumber of tiles along the fourth dimension
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ tile() [1/2]

AFAPI array tile ( const array in,
const dim4 dims 
)

C++ Interface to generate a tiled array.

Each component of dims includes the original in the count. Thus, if no duplicates are needed in a certain dimension, it is left as 1, the default value for just one copy.

Parameters
[in]ininput array
[in]dimsnumber of times in is copied along each dimension
Returns
tiled array

◆ tile() [2/2]

AFAPI array tile ( const array in,
const unsigned  x,
const unsigned  y = 1,
const unsigned  z = 1,
const unsigned  w = 1 
)

C++ Interface to generate a tiled array.

Note, x, y, z, and w include the original in the count.

Parameters
[in]ininput array
[in]xnumber tiles along the first dimension
[in]ynumber tiles along the second dimension
[in]znumber tiles along the third dimension
[in]wnumber tiles along the fourth dimension
Returns
tiled array