MMult(A1: Array; A2: Array): Array;
MMult(A1: System.Array; A2: System.Array): System.Array;
A1. Array of real numbers.
A2. Array of real numbers.
The MMult method returns a product of set matrices.
The resulting array will have the same number of rows as A1 and the same number of columns as A2.
The number of columns of A1 argument must be the same as the number of rows of A2 argument.
To execute this example, add a link to the Stat system assembly.
Sub UserProc;
Var
MM, matr1, matr2: Array Of Double;
i, j: Integer;
Begin
matr1 := New Double[3, 3];
matr1[0, 0] := 1; matr1[0, 1] := 9; matr1[0, 2] := 9;
matr1[1, 0] := 2; matr1[1, 1] := 15; matr1[1, 2] := 4;
matr1[2, 0] := 8; matr1[2, 1] := 1; matr1[2, 2] := 13;
matr2 := New Double[3, 2];
matr2[0, 0] := 10; matr2[0, 1] := 3;
matr2[1, 0] := 20; matr2[1, 1] := 16;
matr2[2, 0] := 18; matr2[2, 1] := 17;
MM := Math.MMult(matr1,matr2);
If math.Status = 0 Then
For i := 0 To MM.GetUpperBound(1) Do
For j := 0 To MM.GetUpperBound(2) Do
Debug.Write(MM[i, j].ToString + " ");
End For;
Debug.WriteLine("");
End For;
Else
Debug.WriteLine("Error " + Math.Status.ToString + ": " + Math.ErrorMsg);
End If;
End Sub UserProc;
After executing the example the console window displays the matrix that is equal to the product of set matrices.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
NOTE. On working with two-dimension arrays in Fore.NET take into account the following feature: the first index specifies a column, the second index specifies a row.
Imports Prognoz.Platform.Interop.MathFin;
…
Public Shared Sub Main(Params: StartParams);
Var
MM, matr1, matr2: System.Array;
i, j: Integer;
Math: MathClass = New MathClass();
Begin
matr1 := New Double[3, 3];
matr1[0, 0] := 1; matr1[1, 0] := 9; matr1[2, 0] := 9;
matr1[0, 1] := 2; matr1[1, 1] := 15; matr1[2, 1] := 4;
matr1[0, 2] := 8; matr1[1, 2] := 1; matr1[2, 2] := 13;
matr2 := New Double[2, 3];
matr2[0, 0] := 10; matr2[1, 0] := 3;
matr2[0, 1] := 20; matr2[1, 1] := 16;
matr2[0, 2] := 18; matr2[1, 2] := 17;
MM := Math.MMult(matr1,matr2);
If math.Status = 0 Then
For i := 0 To MM.GetUpperBound(0) Do
For j := 0 To MM.GetUpperBound(1) Do
System.Diagnostics.Debug.Write(MM[i, j].ToString() + " ");
End For;
System.Diagnostics.Debug.WriteLine("");
End For;
Else
System.Diagnostics.Debug.WriteLine("Error " + Math.Status.ToString() + ": " + Math.ErrorMsg);
End If;
End Sub;
See also: