Modify dimensions of input array. More...

array moddims (const array &A, int dim0, int dim1=1, int dim2=1, int dim3=1)
 This function changes the dimensions of an array. More...
 
array moddims (const array &A, const dim4 &dims)
 This function changes the dimensions of an array. More...
 

Detailed Description

Modify dimensions of input array.

Function Documentation

array af::moddims ( const array &  A,
int  dim0,
int  dim1 = 1,
int  dim2 = 1,
int  dim3 = 1 
)

This function changes the dimensions of an array.

Moddims returns an array which shares memory space with the input array and has the dimensions specified in the parameters.

No work is done (data is simply shared) so this is effectively a noop. No memory space allocated or deleted. The total number of elements must not change.

array a; //a=[1 4]
// [2 5]
// [3 6]
array b = moddims(a, 2, 3); //b=[1 3 5]
// [2 4 6]
Parameters
[in]Ainput array
[in]dim0new size of 1st dimension
[in]dim1new size of 2nd dimension
[in]dim2new size of 3rd dimension
[in]dim3new size of 4th dimension
Returns
array with modified dimensions
Examples:
examples/machine_learning/kmeans.cpp, examples/machine_learning/neuralnetwork.cpp, examples/pde/swe.cpp, and examples/visualization/blip.cpp.
array af::moddims ( const array &  A,
const dim4 &  dims 
)

This function changes the dimensions of an array.

Moddims returns an array which shares memory space with the input array and has the dimensions specified in the parameters.

No work is done (data is simply shared) so this is effectively a noop. No memory space allocated or deleted. The total number of elements must not change.

array a; //a=[1 4]
// [2 5]
// [3 6]
dim4 dims(2, 3);
array b = moddims(a, dims); //b=[1 3 5]
// [2 4 6]
Parameters
[in]Ainput array
[in]dimsnew dimensions
Returns
array with modified dimensions