Investment Studio > Expressions > Functions > Matrix > SUMPRODUCT

float sumproduct(float array a, float array b [, ...])

Returns the sum of the products of all corresponding elements in the argument arrays. At least two arrays are required, preferably with the same dimensions.

Arrays with different dimensions are allowed as long as they all have the same number of elements (e.g. 2 x 3 and 3 x 2 arrays). Corresponding elements are determined by order of appearance (reading from left to right, top to bottom).

Non-numeric array elements are automatically converted to numbers. If conversion fails, they are treated as zeros.

Examples

=sumproduct({{1, 2}, {3, 4}}, {{5, "6"}, {7, ""}})

equals 1 * 5 + 2 * 6 + 3 * 7 + 4 * 0 = 38. The string "6" is autotranslated to 6, the string "" has no numeric value and so defaults to 0.

=sumproduct({{1, 2}, {3, 4}, {5, 6}}, {{1, 2, 3} , {4, 5, 6}})

equals 1 * 1 + 2 * 2 + 3 * 3 + 4 * 4 + 5 * 5 + 6 * 6 = 91.

See also mmult, product, sum, sumx2my2, sumx2py2, sumxmy2.