Repeat the contents of the input array along the specified dimensions. More...

Functions

AFAPI array tile (const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
 
AFAPI array tile (const array &in, const dim4 &dims)
 
AFAPI af_err af_tile (af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
 

Detailed Description

Repeat the contents of the input array along the specified dimensions.

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 essentially a set of "tiles", where each copy of the input array (including the original) is a "tile" (hence the name of this function).

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 
)
Parameters
[out]outis the tiled version of the input array
[in]inis the input matrix
[in]xis the number of times in is copied along the first dimension
[in]yis the number of times in is copied along the the second dimension
[in]zis the number of times in is copied along the third dimension
[in]wis the number of times in is copied along the fourth dimension
Note
x, y, z, and w includes the original in the count as well. Thus, if no duplicates are needed in a certain dimension, leave it as 1 (the default value for just one copy)

◆ tile() [1/2]

AFAPI array af::tile ( const array in,
const dim4 dims 
)
Parameters
[in]inis the input array
[in]dimsspecifies the number of times in is copied along each dimension
Returns
The tiled version of the input array
Note
Each component of dims includes the original in the count as well. Thus, if no duplicates are needed in a certain dimension, leave it as 1 (the default value for just one copy)

◆ tile() [2/2]

AFAPI array af::tile ( const array in,
const unsigned  x,
const unsigned  y = 1,
const unsigned  z = 1,
const unsigned  w = 1 
)
Parameters
[in]inis the input array
[in]xis the number of times in is copied along the first dimension
[in]yis the number of times in is copied along the the second dimension
[in]zis the number of times in is copied along the third dimension
[in]wis the number of times in is copied along the fourth dimension
Returns
The tiled version of the input array
Note
x, y, z, and w includes the original in the count as well. Thus, if no duplicates are needed in a certain dimension, leave it as 1 (the default value for just one copy)
Examples
benchmarks/cg.cpp, computer_vision/matching.cpp, financial/black_scholes_options.cpp, getting_started/vectorize.cpp, graphics/conway_pretty.cpp, graphics/field.cpp, graphics/gravity_sim.cpp, image_processing/filters.cpp, image_processing/image_editing.cpp, machine_learning/bagging.cpp, machine_learning/deep_belief_net.cpp, machine_learning/kmeans.cpp, machine_learning/knn.cpp, machine_learning/naive_bayes.cpp, machine_learning/rbm.cpp, and pde/swe.cpp.
afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:327
af::tile
AFAPI array tile(const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)