TUdataMxMn TCL UTILITIES USER MANUAL TUdataMxMn
SYNOPSIS
Determine the minimum and/or maximum values in an array
PACKAGE
TCLUTILS
NAME
TUdataMxMn
USAGE
set rV  [TUdataMxMn  D nE {Cond} {lLim} {uLim} {Skip} {Off}]
INPUT DEFINITIONS
D - Input data array
nE - The number elements to process. The last data array element processed is (nE - 1) * Skip + Off.
Cond - Return condition:
> - Return index of maximum value
< - Return index of minimum value
<> - Return indices of minimum and maximum values
lLim - Optional lower limit. Values below this limit are omited in the search. Default is -9.0e30.
uLim - Optional upper limit. Values above this limit are omited in the search. Default is 9.0e30.
Skip - Optional increment value to use when getting the next value in the data array. Default is 1.
Off - Optional offset into the data array. Processing starts at this element. Default is 0.
RETURN DEFINITION
rV - List of offsets into data array to the minimum, maximum, or minimum and maximum values depending on whether the search condition was <, >, or <> respectively.
DESCRIPTION
TUdataMxMn determines the locations of the maximum and/or maximum values in the input array D. The result is returned through the procedure as a list. The routine provides for optional upper and lower cutoff values as well as an offset into the input array and and increment value to use when parsing the data array. The latter two options are generally used when an array contains an ordered set of data such as a set of (X,Y,Z) data.
ERRORS
None Generated
C BACKING
Yes
EXAMPLE(S)
# SET up an array of 20 XYZ values

set V -30.0
for { set I 0 } { $I < 60 } { } {
   set A($I) $V  
   incr I ;  set V [expr $V + 1.0]
   set A($I) [expr -$V] 
   incr I ; set V [expr $V + 1.0]
   set A($I) [expr exp (-sqrt(($V + 2) * ($V + 2))) / 30.0 ] 
   incr I ; set V [expr $V + 1.0]
}

# SOLVE for max and min values of X, Y, and Z 

set rV [TUdataMxMn A 20 <> -1.0e30 1.0e30 3 0 ]
set MnI [lindex $rV 0]
set MxI [lindex $rV 1]
puts stderr "X (min,max) - \
     Indices: [format "%2d %2d" $MnI $MxI]  \
     Values: [format "%.2e %.2e" $A($MnI) $A($MxI)]"
set rV [TUdataMxMn A 20 <> -1.0e30 1.0e30 3 1 ]
set MnI [lindex $rV 0]
set MxI [lindex $rV 1]
puts stderr "Y (min,max) - \
     Indices: [format "%2d %2d" $MnI $MxI]  \
     Values: [format "%.2e %.2e" $A($MnI) $A($MxI)]"
set rV [TUdataMxMn A 20 <> -1.0e30 1.0e30 3 2 ]
set MnI [lindex $rV 0]
set MxI [lindex $rV 1]
puts stderr "Z (min,max) - \
     Indices: [format "%2d %2d" $MnI $MxI]  \
     Values: [format "%.2e %.2e" $A($MnI) $A($MxI)]"

> X (min,max) -  Indices:  0 57   Values: -3.00e+01 2.70e+01
> Y (min,max) -  Indices: 58  1   Values: -2.80e+01 2.90e+01
> Z (min,max) -  Indices: 59 29   Values: 1.15e-15 1.23e-02

      
June 4, 2003