TUarrayMath TCL UTILITIES USER MANUAL TUarrayMath
SYNOPSIS
A set of mathematical operations applicable to array data.
PACKAGE
TCLUTILS
NAME
TUarrayMath
USAGE
set rV  [TUarrayMath  A Op B C nE {oA} {oB} {oC} {dA} {dB} {dC}]
INPUT DEFINITIONS
A - Input data array A
Op - Operation
ACOS - Take acos of A returning angle in radians in array C
ACOSD - Take acos of A returning angle in degrees in array C
ATAN - Take atan of A returning angle in radians in array C
ATAND - Take atan of A returning angle in degrees in array C
AVG - Find average of A returning single value through the routine
LOG10 - Take log base 10 of A and return in array C.
LOGE - Take log base e of A and return in array C.
SUM - Return the sum of A through the routine.
SUM - Return the varience of A through the routine.
OP - Produce the operation A OP B and return the result in C. OP must be a valid mathematical operation (*, +, %, etc). If B is a constant then it is applied to all elements in A.
B - Input data array B. (Used only when two array operations are specified.)
C - Output data array C. (Used only when the result of an operation is itself an array.)
nE - The number elements to process. The last data array element processed is (nE - 1) * oX + dX where X is A, B or C as defined below.
oA - Optional offset into array A. Default is 0.
oB - Optional offset into array B. Default is 0.
oC - Optional offset into array C. Default is 0.
dA - Optional increment value to use when getting the next value in array A. Default is 1.
dB - Optional increment value to use when getting the next value in array B. Default is 1.
dC - Optional increment value to use when putting the next value in array C. Default is 1.
RETURN DEFINITION
rV - All constant values are returned through the procedure.
DESCRIPTION
TUarrayMath performs mathematical operations on a single array of values or between two arrays. If the the returned result is an array of values then the result is returned in array C otherwise it is returned through the routine. The offsets oA, oB, and oC allow arbitrary offsets into the input and output arrays while dA, dB and dC allows for non-sequential indexing.
ERRORS
None Generated
C BACKING
Yes
EXAMPLE(S)
# SET up an array and array of angles in degrees

for { set I 0 } { $I < 36 } { incr I } { set A($I) [expr double($I * 10)] }

# COMPUTE cos**2 + sin **2 

TUarrayMath A COSD B C 36
TUarrayMath A SIND B D 36
TUarrayMath C * C E 36
TUarrayMath D * D F 36
TUarrayMath E + F G 36

# PRINT out every fourth array value

for { set I 0 } { $I < 36 } { incr I 4 } { 
   puts stderr "Value $I : [format "%.3f" $G($I)]"
}

> Value 0 : 1.000
> Value 4 : 1.000
> Value 8 : 1.000
> Value 12 : 1.000
> Value 16 : 1.000
> Value 20 : 1.000
> Value 24 : 1.000
> Value 28 : 1.000
> Value 32 : 1.000

      
June 4, 2003