ArrayOp2
(Engine-Level Function)
Description: | Performs a mathematical operation on an array with respect to another array. |
Returns: | Nothing |
Usage: | Script only. |
Function Groups: | Array |
Related to: | ArrayOp1 | ArraySize | FFT| Array Functions | WhileLoop |
Format: | ArrayOp2(DestinationElement, SourceElement, N, OpCode[, MaskElement]) |
Parameters: |
DestinationElement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required. Any array element giving the starting point for the array operation in the destination array. The subscript for the array may be any numeric expression. If processing a multidimensional array, only the right-most dimension is used. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SourceElement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required. Any array element giving the starting point for the array operation in the source array. The subscript for the array may be any numeric expression. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
N | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required. Any numeric expression giving the number of array elements to compute. N will be limited to the minimum of (N, Source length, Destination length). If the starting point given by the first parameter is not the first element, and therefore N extends past the upper bound of the lowest array dimension, this computation will "wrap-around" and resume at the first element. Because N is automatically limited by the smallest array dimension, no element will be processed twice. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OpCode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required. Any numeric expression giving the operation number to perform as follows (note that A is an element of Array1 and B is an element of Array2):
|
MaskElement |
Optional. The starting element in an array of TRUE and FALSE values, specifying which elements in array, A will be operated upon. The ArrayOp function will only apply to element A[i] if Mask[starting element + i] is a valid TRUE. |
Comments: |
The ArrayOp2 statement is useful for large amounts of repetitive computation. While this can be done by executing a script repeatedly using WhileLoop, the ArrayOp2 statement is much faster. Complex computations may be broken down into a series of simple steps and handled by multiple ArrayOp1 and ArrayOp2 statements. If text arrays are used, each text value will be converted to a number before the numerical operations are performed. The resulting array is converted back to text. For a multi-dimensional array such as A[X][Y], only the right-most dimension is processed. ([Y] in this example.) You must resort to loops to process the other array dimensions. |
Example:
If 1 Main; [ Destination = New(ArraySize(Source)); ArrayOp2(Destination[0], Source[0], ArraySize(Source), 0 {copy}); ]
This example creates a copy of the array, Source.