Mtranspose(Data: Array): Array;
Data. Single dimension or two dimension number array.
The Mtranspose method returns transposed array.
Transposing is transformation of an array that results in columns becoming rows and rows becoming columns.
Add link to the MathFin system assembly.
Sub UserProc;
Var
Matr, MInv: Array Of Double;
i, j: integer;
Begin
// Create two dimension array
Matr := New Double[3, 3];
Matr[0, 0] := 1; Matr[0, 1] := 9; Matr[0, 2] := 9;
Matr[1, 0] := 2; Matr[1, 1] := 15; Matr[1, 2] := 0;
Matr[2, 0] := 8; Matr[2, 1] := 2; Matr[2, 2] := 13;
Debug.WriteLine("Array");
// Display created array to console
For i := 0 To Matr.GetUpperBound(1) Do
For j := 0 To Matr.GetUpperBound(2) Do
Debug.Write(Matr[i, j].ToString + " ");
End For;
Debug.WriteLine("");
End For;
// Transpose array
MInv := Math.Mtranspose(Matr);
Debug.WriteLine("Transposed array");
// Display transposed array in the console
For i := 0 To MInv.GetUpperBound(1) Do
For j := 0 To MInv.GetUpperBound(2) Do
Debug.Write(MInv[i, j].ToString + " ");
End For;
Debug.WriteLine("");
End For;
End Sub UserProc;
After executing the example the MInv variable contains the Matr transposed array, and both arrays are displayed in the console window.
See also: