# Octave max

```>> help max
'max' is a built-in function from the file libinterp/corefcn/max.cc

-- max (X)
-- max (X, [], DIM)
-- [W, IW] = max (X)
-- max (X, Y)
Find maximum values in the array X.

For a vector argument, return the maximum value.  For a matrix
argument, return a row vector with the maximum value of each
column.  For a multi-dimensional array, 'max' operates along the
first non-singleton dimension.

If the optional third argument DIM is present then operate along
this dimension.  In this case the second argument is ignored and
should be set to the empty matrix.

For two matrices (or a matrix and a scalar), return the pairwise
maximum.

Thus,

max (max (X))

returns the largest element of the 2-D matrix X, and

max (2:5, pi)
=>  3.1416  3.1416  4.0000  5.0000

compares each element of the range '2:5' with 'pi', and returns a
row vector of the maximum values.

For complex arguments, the magnitude of the elements are used for
comparison.  If the magnitudes are identical, then the results are
ordered by phase angle in the range (-pi, pi].  Hence,

max ([-1 i 1 -i])
=> -1

because all entries have magnitude 1, but -1 has the largest phase
angle with value pi.

If called with one input and two output arguments, 'max' also
returns the first index of the maximum value(s).  Thus,

[x, ix] = max ([1, 3, 5, 2, 5])
=>  x = 5
ix = 3