SumProduct(Values: Variant): Double;
Values. Arrays, which elements must be multiplied and then added.
The SumProduct method multiplies the corresponding elements of the specified arrays and returns the sum of products.
The Values parameter must be a number array.
To get the sum of real numbers, use the IMath.Sum method.
Consider an example. There are three vectors from four elements:
V1[2,3,6,7].
V2[1,5,2,6].
V3[8,1,3,4].
The V4 vector, containing the multiplication results, will look like this: V4[16,15,36,168].
Thus, the result of calculating this method for these three vectors will be the number 235, which is the sum of elements of the vector V4.
To execute the example, add a link to the MathFin system assembly.
Sub UserProc;
Var
r: Double;
a: Array[1..3,1..4] Of Variant;
Begin
a[1, 1] := 2; a[1, 2] := 3; a[1, 3] := 6; a[1, 4] := 7;
a[2, 1] := 1; a[2, 2] := 5; a[2, 3] := 2; a[2, 4] := 6;
a[3, 1] := 8; a[3, 2] := 1; a[3, 3] := 3; a[3, 4] := 4;
r := Math.SumProduct(a);
Debug.WriteLine(r);
End Sub UserProc;
After executing the example the console window displays the sum of products.
See also: