IMatrixModel.OperationMatrix

Syntax

OperationMatrix(Op: MatrixOperation; Source: IMatrixModel);

Parameters

Op. Mathematical operation, which must be executed for the original matrix and the matrix passed by the Source parameter.

Source. The matrix that is used in mathematical operation with the current matrix.

Description

The OperationMatrix method executes mathematical operations between the current matrix and the matrix passed by the Source input parameter. The result is placed into the current matrix. All operations are executed elementwise.

Example

Sub Main;

Var

M1, M2: Matrix[2];

Mm: IMatrixModel;

x, y: Integer;

Begin

Debug.WriteLine("Parent matrices");

For x := 0 To 3 Do

For y := 0 To 3 Do

M1[x, y] := Math.RandBetweenI(0, 10);

Debug.Write(M1[x, y] + " ");

End For;

Debug.WriteLine("");

End For;

Debug.WriteLine("------------");

For x := 0 To 3 Do

For y := 0 To 3 Do

M2[x, y] := Math.RandBetweenI(0, 10);

Debug.Write(M2[x, y] + " ");

End For;

Debug.WriteLine("");

End For;

Mm := M1 As IMatrixModel;

Mm.OperationMatrix(MatrixOperation.Mul, (M2 As IMatrixModel));

Debug.WriteLine("------------");

For x := 0 To 3 Do

For y := 0 To 3 Do

Debug.Write(M1[x, y] + " ");

End For;

Debug.WriteLine("");

End For;

End Sub Main;

After executing the example two matrices with random values will be created. They will be multiplied elementwise. The source and output data will be displayed in the development environment console.

See also:

IMatrixModel