IMath.SumProduct

Syntax

SumProduct(Values: Variant): Double;

Parameters

Values. Arrays, which elements must be multiplied and then added.

Description

The SumProduct method multiplies the corresponding elements of the specified arrays and returns the sum of products.

Comments

The Values parameter must be a number array.

To get the sum of real numbers, use the IMath.Sum method.

Example

Consider an example. There are three vectors from four elements:

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..4Of Variant;
Begin
    a[11] := 2; a[12] := 3; a[13] := 6; a[14] := 7;
    a[21] := 1; a[22] := 5; a[23] := 2; a[24] := 6;
    a[31] := 8; a[32] := 1; a[33] := 3; a[34] := 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:

IMath