Warning: This file is not a C or C++ file. It does not have highlighting.

1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CXX03___NUMERIC_INNER_PRODUCT_H
11#define _LIBCPP___CXX03___NUMERIC_INNER_PRODUCT_H
12
13#include <__cxx03/__config>
14#include <__cxx03/__utility/move.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_PUSH_MACROS
21#include <__cxx03/__undef_macros>
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _InputIterator1, class _InputIterator2, class _Tp>
26_LIBCPP_HIDE_FROM_ABI _Tp
27inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) {
28 for (; __first1 != __last1; ++__first1, (void)++__first2)
29 __init = __init + *__first1 * *__first2;
30 return __init;
31}
32
33template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
34_LIBCPP_HIDE_FROM_ABI _Tp inner_product(
35 _InputIterator1 __first1,
36 _InputIterator1 __last1,
37 _InputIterator2 __first2,
38 _Tp __init,
39 _BinaryOperation1 __binary_op1,
40 _BinaryOperation2 __binary_op2) {
41 for (; __first1 != __last1; ++__first1, (void)++__first2)
42 __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
43 return __init;
44}
45
46_LIBCPP_END_NAMESPACE_STD
47
48_LIBCPP_POP_MACROS
49
50#endif // _LIBCPP___CXX03___NUMERIC_INNER_PRODUCT_H
51

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxx/include/__cxx03/__numeric/inner_product.h