Inform me () when using this script or encorporating it in a library.
Source code of min_val.pro:
;+
; NAME:
; MIN_VAL
; PURPOSE:
; Get the minimum value of each row in the input 2D matrix as a
; value in the return array
; CALLING SEQUENCE:
; min_val, x
; EXAMPLES:
; a = randomn(0,10)
; b = randomn(10,10)
; result = min_val(transpose(a),transpose(b))
; returns an array with the minimum values of a and b
; KEYWORDS:
; x = input 2 dimensional array
; idx = the index of column of the maximum value
; MODIFICATION HISTORY:
; 09/09/2004 Written by Eduard Westra
;-
FUNCTION min_val, x, idx=idx, help=help
IF (KEYWORD_SET(HELP)) THEN BEGIN & doc_library,'min_val' & RETURN, 0 & ENDIF
IF (N_ELEMENTS(x) EQ 0) THEN BEGIN & doc_library,'min_val' & RETURN, 0 & ENDIF
IF (size(x, /n_dimensions) GT 2) THEN BEGIN & MESSAGE,/inform, 'Input is not a 2D array' & RETURN, x & ENDIF
n_el = N_ELEMENTS(x)
IF (size(x, /n_dimensions) EQ 1) THEN BEGIN
IF (n_el MOD 2 EQ 0) THEN BEGIN
MESSAGE, /inform, 'Input array is 1D, splitting it in two'
xx = TRANSPOSE(REFORM(x, n_el/2, 2))
ENDIF ELSE BEGIN
MESSAGE, /inform, 'Input array is 1D, but odd size. Cannot split!' & RETURN, x
ENDELSE
ENDIF ELSE BEGIN
xx = x
ENDELSE
size = SIZE(xx)
ncols = size[1]
nrows = size[2]
type = size[3]
result = MAKE_ARRAY(nrows, type=type)
result = transpose(xx[0,*])
idx = INTARR(nrows)
FOR i=0, ncols-2 DO BEGIN
result = result < transpose(xx[i+1,*])
idx = idx > (i+1)*(result EQ transpose(xx[i+1,*]))
ENDFOR
RETURN, result
END