The C++ interface for max. More...

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

Detailed Description

The C++ interface for max.

Returns the maximum value of an array, or if specified, the
maximum value of each dimension of the array. Max can also
return the indices (0-based) where these elements are located.
int hx[] = { -3, -5, 2, -9 };
// hx = -3 2
// -5 -9
array x(2,2, hx); // 2x2 matrix
float value;
int index;
max(&value, &index, x);
printf("%g,%d\n", value, index)); // 2,2

Return the maximum 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", max<int>(x1), max<int>(x2)); // 2, 2

Return maximum 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;
// max along columns
max(m, i, in, 0);
print(m);
print(i);
// m = 2.0000 4.0000
// i = 1 1
// max along rows
max(m, i, in, 1);
print(m);
print(i);
// m = 3.0000
// 4.0000
// i = 1
// 1

Function Documentation

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

Maximum 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 maximum values along the dimension dim in the input
void af::max ( array &  values,
array &  indices,
const array &  input,
int  dim = -1 
)

Maximum value and index found along dimension.

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

Maximum value among all elements in array.

int hx[] = { -3, -5, 2, -9 };
array x1(2,2, hx); // 2x2 matrix
array x2(4,1, hx); // 4x1 vector
printf("%d,%d\n", max<int>(x1), max<int>(x2)); // 2,2
Parameters
[in]input
Returns
maximum of all values in the input array
void af::max ( ty *  value,
int *  index,
const array &  input 
)

Maximum value and index among all elements in array.

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