Returns the size and number of dimensions of the array objects. More...

dim4 dims () const
 Return a dim4 object with the dimensions of the array. More...
 
int dims (unsigned dim) const
 Return the size of the dimension specified by index dim (zero-indexed). More...
 
int numdims () const
 Returns the number of dimensions whose size is greater then one. More...
 

Detailed Description

Returns the size and number of dimensions of the array objects.

These functions return the size and number of the dimensions of the array object.

Function Documentation

dim4 dims ( ) const

Return a dim4 object with the dimensions of the array.

array a(4,5,6);
//create array of the same size
array b(a.dims());
Returns
A dim4 object with the dimension of the array
Examples:
examples/financial/blackscholes.cpp, examples/image_processing/optical_flow.cpp, examples/machine_learning/kmeans.cpp, and examples/machine_learning/neuralnetwork.cpp.
int dims ( unsigned  dim) const

Return the size of the dimension specified by index dim (zero-indexed).

array a(4,5);
printf("%d,%d\n",a.dims(0),a.dims(1)); // 4,5
Parameters
[in]dimThe dimension to query
Returns
The size of the dim dimension
int numdims ( ) const

Returns the number of dimensions whose size is greater then one.

array a = constant(0,4,5,6);
cout << a.dims().numdims() << endl;
//Returns 3
Returns
The number of dimensions greater then 1