Array.ArrayOperation

Syntax

ArrayOperation(OperationType: ArrayOperationType, Value: Variant);

Parameters

OperationType. Type of arithmetic operation.

Value. Array that will be used to execute an operation with source array elements.

Description

The ArrayOperation method executes arithmetic operation with array elements.

Comments

To execute an arithmetic operation, the arrays in use should contain the equal number of elements and dimensions.

Example

To execute the example, add a link to the MathFin system assembly.

Sub UserProc;
Var
    Matr, Matr2: Array Of Double;
    i, j: Integer;
Begin
    // Create a two-dimensional array
    Matr := New Double[33];
    Matr[00] := 4; Matr[01] := 9; Matr[02] := 3;
    Matr[10] := 2; Matr[11] := 15; Matr[12] := 7;
    Matr[20] := 8; Matr[21] := 5; Matr[22] := 13;
    Debug.WriteLine("The first array before operation execution:");
    // Display the created array in the console
    For i := 0 To Matr.GetUpperBound(1Do
        For j := 0 To Matr.GetUpperBound(2Do
            Debug.Write(Matr[i, j].ToString + " ");
        End For;
        Debug.WriteLine("");
    End For;
    // Create a two-dimensional array that will be used during the operation
    Matr2 := New Double[33];
    Matr2[00] := 1; Matr2[01] := 2; Matr2[02] := 1;
    Matr2[10] := 2; Matr2[11] := 1; Matr2[12] := 5;
    Matr2[20] := 3; Matr2[21] := 4; Matr2[22] := 2;
    Debug.WriteLine("The second array for operation execution:");
    // Display the created array in the console
    For i := 0 To Matr2.GetUpperBound(1Do
        For j := 0 To Matr2.GetUpperBound(2Do
            Debug.Write(Matr2[i, j].ToString + " ");
        End For;
        Debug.WriteLine("");
    End For;
    // Execute arithmetic operation with array elements
    Matr.ArrayOperation(ArrayOperationType.Minus, Matr2);
    // Display operation result in the console
    Debug.WriteLine("The first array after operation execution:");
    For i := 0 To Matr.GetUpperBound(1Do
        For j := 0 To Matr.GetUpperBound(2Do
            Debug.Write(Matr[i, j].ToString + " ");
        End For;
        Debug.WriteLine("");
    End For;
End Sub UserProc;

After executing the example the console will display the array before and after operation execution. On executing the operation, values of elements of the first array are decreased by values of elements of the second array:

The first array before operation execution:

4 9 3

2 15 7

8 5 13

The second array before operation execution:

1 2 1

2 1 5

3 4 2

The first array after operation execution:

3 7 2

0 14 2

5 1 11

See also:

Array