Name

inner_product function template — Computes inner product of two ranges

Synopsis

template <typename InIter1, typename InIter2, typename T>
T inner_product(InIter1 first1, InIter1 last1, InIter2 first2, T init);
template <typename InIter1, typename InIter2, typename T, 
          typename BinaryOp1, typename BinaryOp2>
T inner_product(InIter1 first1, InIter1 last1, InIter2 first2, T init,
                BinaryOp1 binary_op1, BinaryOp2 binary_op2);

The inner_product function template computes an inner product of two ranges. It accumulates the products of corresponding items in [first1, last1) and [first2, last2), in which last2 = first2 + (last1 - first1). The second version calls binary_op1 as the accumulator operator (instead of addition) and binary_op2 as the multiplication operator.