The C++ interface for min. More...

array min (const array &input, int dim=-1)
 Minimum of the elements along a dimension in matrix. More...
 
void min (array &values, array &indices, const array &input, int dim=-1)
 Minimum value and index found along dimension. More...
 
template<typename ty >
ty min (const array &input)
 Minimum value among all elements in array. More...
 
template<typename ty >
void min (ty *value, int *index, const array &input)
 Minimum value and index among all elements in array. More...
 

Detailed Description

The C++ interface for min.

Returns the minimum value of an array, or if specified, the
minimum value of each dimension of the array. min can
also return the index of the minimum element:
int hx[] = { -3, -5, 2, -9 };
// hx = -3 2
// -5 -9
array x(2,2, hx); // 2x2 matrix
float value;
int index;
min(&value, &index, x);
printf("%g,%d\n", value, index)); // -9,3

Return the minimum regardless of dimension:

int hx[] = { -3, -5, 2, -9 };
array x1(2,2, hx); // 2x2 matrix
array x2(4,1, hx); // 4x1 vector
printf("%d,%d\n", min<int>(x1), min<int>(x2)); // -9,-9

Return minimum and indices along a given dimension

float ha[] = {1, 2, 3, 4};
array in = array(2, 2, ha);
// Storage for the results
array m, i;
// Min along columns
min(m, i, in, 0);
print(m);
print(i);
// m = 1.0000 3.0000
// i = 0 0
// Min along rows
min(m, i, in, 1);
print(m);
print(i);
// m = 1.0000
// 2.0000
// i = 0
// 0

Function Documentation

array af::min ( const array &  input,
int  dim = -1 
)

Minimum of the elements along a dimension in matrix.

Parameters
[in]input
[in]dimdimension along which to operate (-1 indicates first non-singleton dimension)
Returns
array with minimum values along the dimension dim in the input
void af::min ( array &  values,
array &  indices,
const array &  input,
int  dim = -1 
)

Minimum value and index found along dimension.

Parameters
[in]input
[in]dimdimension along which to operate (-1 indicates first non-singleton dimension)
[out]valuesarray with minimum values along the dimension dim in input
[out]indiceslocation where values occur in input (zero-based indexing)
ty af::min ( const array &  input)

Minimum value among all elements in array.

Parameters
[in]input
Returns
minimum of all values in the input array
void af::min ( ty *  value,
int *  index,
const array &  input 
)

Minimum value and index among all elements in array.

Parameters
[in]input
[out]valuearray with minimum values along the dimension dim in input
[out]indexlocation where values occur in input (zero-based indexing)