IMatrix.Swap

Syntax

Swap(SwapInfo: IMatrixModelSwapInfo): IMatrix;

Parameters

SwapInfo - information about swapped dimensions in a matrix.

Description

The Swap method swaps dimensions with data in a matrix. Information about swapped dimensions is passed by the SwapInfo parameter.

Example

Sub Main;

Var

M: Matrix[3];

Mm: IMatrixModel;

Swap: IMatrixModelSwapInfo;

x, y, z: Integer;

Begin

Debug.WriteLine("Source matrix");

For x := 1 To 3 Do

For y := 1 To 3 Do

For z := 1 To 3 Do

M[x, y, z] := Math.RandBetweenI(0, 9);

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

End For;

Debug.WriteLine("");

End For;

Debug.WriteLine("");

End For;

Mm := M As IMatrixModel;

Swap := (M As IMatrix).CreateSwapInfo;

Swap.Swap(0, 1);

M := (M As IMatrix).Swap(Swap);

Debug.WriteLine("Matrix with swapped dimensions");

For x := 1 To 3 Do

For y := 1 To 3 Do

For z := 1 To 3 Do

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

End For;

Debug.WriteLine("");

End For;

Debug.WriteLine("");

End For;

End Sub Main;

After executing the example a matrix with random values is created. The first and second dimensions in this matrix are swapped.

See also:

IMatrix