2 * Copyright 2008-2013 NVIDIA Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 /*! \file inner_product.inl
19 * \brief Inline file for inner_product.h.
22 #include <thrust/detail/config.h>
23 #include <thrust/inner_product.h>
24 #include <thrust/iterator/iterator_traits.h>
25 #include <thrust/system/detail/generic/select_system.h>
26 #include <thrust/system/detail/generic/inner_product.h>
27 #include <thrust/system/detail/adl/inner_product.h>
33 template<typename DerivedPolicy,
34 typename InputIterator1,
35 typename InputIterator2,
37 OutputType inner_product(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
38 InputIterator1 first1,
40 InputIterator2 first2,
43 using thrust::system::detail::generic::inner_product;
44 return inner_product(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first1, last1, first2, init);
45 } // end inner_product()
48 template<typename DerivedPolicy,
49 typename InputIterator1,
50 typename InputIterator2,
52 typename BinaryFunction1,
53 typename BinaryFunction2>
54 OutputType inner_product(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
55 InputIterator1 first1,
57 InputIterator2 first2,
59 BinaryFunction1 binary_op1,
60 BinaryFunction2 binary_op2)
62 using thrust::system::detail::generic::inner_product;
63 return inner_product(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first1, last1, first2, init, binary_op1, binary_op2);
64 } // end inner_product()
67 template <typename InputIterator1, typename InputIterator2, typename OutputType>
69 inner_product(InputIterator1 first1, InputIterator1 last1,
70 InputIterator2 first2, OutputType init)
72 using thrust::system::detail::generic::select_system;
74 typedef typename thrust::iterator_system<InputIterator1>::type System1;
75 typedef typename thrust::iterator_system<InputIterator2>::type System2;
80 return thrust::inner_product(select_system(system1,system2), first1, last1, first2, init);
81 } // end inner_product()
84 template <typename InputIterator1, typename InputIterator2, typename OutputType,
85 typename BinaryFunction1, typename BinaryFunction2>
87 inner_product(InputIterator1 first1, InputIterator1 last1,
88 InputIterator2 first2, OutputType init,
89 BinaryFunction1 binary_op1, BinaryFunction2 binary_op2)
91 using thrust::system::detail::generic::select_system;
93 typedef typename thrust::iterator_system<InputIterator1>::type System1;
94 typedef typename thrust::iterator_system<InputIterator2>::type System2;
99 return thrust::inner_product(select_system(system1,system2), first1, last1, first2, init, binary_op1, binary_op2);
100 } // end inner_product()
103 } // end namespace thrust