Compute the maximum value of an array. More...

Modules

 max
 The C++ interface for max.
 
 af_max
 the C interface for max
 

Detailed Description

Compute the maximum value of an array.

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