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 to modify the dimensions of an input array to a specified shape. More...
 
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 to modify the dimensions of an input array to a specified shape. More...
 
AFAPI array moddims (const array &in, const unsigned ndims, const dim_t *const dims)
 C++ Interface to modify the dimensions of an input array to a specified shape. More...
 
AFAPI af_err af_moddims (af_array *out, const af_array in, const unsigned ndims, const dim_t *const dims)
 C Interface to modify the dimensions of an input array to a specified shape. More...
 

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 to modify the dimensions of an input array to a specified shape.

Parameters
[out]outmodded output
[in]ininput array
[in]ndimsnumber of dimensions
[in]dimsnew dimension sizes
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ moddims() [1/3]

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

C++ Interface to modify the dimensions of an input array to a specified shape.

Parameters
[in]ininput array
[in]dimsnew dimension sizes
Returns
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 to modify the dimensions of an input array to a specified shape.

Parameters
[in]ininput array
[in]d0new size of the first dimension
[in]d1new size of the second dimension (optional)
[in]d2new size of the third dimension (optional)
[in]d3new size of the fourth dimension (optional)
Returns
modded output

◆ moddims() [3/3]

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

C++ Interface to modify the dimensions of an input array to a specified shape.

Parameters
[in]ininput array
[in]ndimsnumber of dimensions
[in]dimsnew dimension sizes
Returns
modded output