A high-performance general-purpose compute library

Modify the dimensions of an array without changing the order of its elements. More...

Functions

AFAPI array moddims (const array &in, const dim4 &dims)
 C++ Interface for modifying the dimensions of an input array to the shape specified by a dim4 object.
 
AFAPI array moddims (const array &in, const dim_t d0, const dim_t d1=1, const dim_t d2=1, const dim_t d3=1)
 C++ Interface for modifying the dimensions of an input array to the shape specified by dimension length parameters.
 
AFAPI array moddims (const array &in, const unsigned ndims, const dim_t *const dims)
 C++ Interface for modifying the dimensions of an input array to the shape specified by an array of ndims dimensions.
 
AFAPI af_err af_moddims (af_array *out, const af_array in, const unsigned ndims, const dim_t *const dims)
 C Interface for modifying the dimensions of an input array to the shape specified by an array of ndims dimensions.
 

Detailed Description

Modify the dimensions of an array without changing the order of its elements.

This function only modifies array metadata and requires no computation. It is a NOOP.

Examples:

// Create a, a 2x3 array
array a = iota(dim4(2, 3)); // a = [0, 2, 4,
// 1, 3, 5]
// Create b by modifying the dimensions of a to the shape described by a dim4 object
array b = moddims(a, dim4(3, 2)); // b = [0, 3,
// 1, 4,
// 2, 5]
// Create c by modifying the dimensions of a to the shape described by dimension length parameters
array c = moddims(a, 3, 2); // c = [0, 3,
// 1, 4,
// 2, 5]
// Create d by modifying the dimensions of a to the shape described by an array of ndims dimensions
vector<dim_t> x{3, 2};
array d = moddims(a, 2, x.data()); // d = [0, 3,
// 1, 4,
// 2, 5]

Function Documentation

◆ af_moddims()

AFAPI af_err af_moddims ( af_array out,
const af_array  in,
const unsigned  ndims,
const dim_t *const  dims 
)

C Interface for modifying the dimensions of an input array to the shape specified by an array of ndims dimensions.

Parameters
[out]outthe modded output
[in]inthe input array
[in]ndimsthe number of dimensions
[in]dimsthe array of new dimension sizes

◆ moddims() [1/3]

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

C++ Interface for modifying the dimensions of an input array to the shape specified by a dim4 object.

Parameters
[in]inthe input array
[in]dimsthe array of new dimension sizes
Returns
the modded output

◆ moddims() [2/3]

AFAPI array moddims ( const array in,
const dim_t  d0,
const dim_t  d1 = 1,
const dim_t  d2 = 1,
const dim_t  d3 = 1 
)

C++ Interface for modifying the dimensions of an input array to the shape specified by dimension length parameters.

Parameters
[in]inthe input array
[in]d0the new size of the first dimension
[in]d1the new size of the second dimension (optional)
[in]d2the new size of the third dimension (optional)
[in]d3the new size of the fourth dimension (optional)
Returns
the modded output

◆ moddims() [3/3]

AFAPI array moddims ( const array in,
const unsigned  ndims,
const dim_t *const  dims 
)

C++ Interface for modifying the dimensions of an input array to the shape specified by an array of ndims dimensions.

Parameters
[in]inthe input array
[in]ndimsthe number of dimensions
[in]dimsthe array of new dimension sizes
Returns
the modded output