OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / detail / inner_product.inl
1 /*
2  *  Copyright 2008-2013 NVIDIA Corporation
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 /*! \file inner_product.inl
19  *  \brief Inline file for inner_product.h.
20  */
21
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>
28
29 namespace thrust
30 {
31
32
33 template<typename DerivedPolicy,
34          typename InputIterator1,
35          typename InputIterator2,
36          typename OutputType>
37 OutputType inner_product(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
38                          InputIterator1 first1,
39                          InputIterator1 last1,
40                          InputIterator2 first2,
41                          OutputType init)
42 {
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()
46
47
48 template<typename DerivedPolicy,
49          typename InputIterator1,
50          typename InputIterator2,
51          typename OutputType,
52          typename BinaryFunction1,
53          typename BinaryFunction2>
54 OutputType inner_product(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
55                          InputIterator1 first1,
56                          InputIterator1 last1,
57                          InputIterator2 first2,
58                          OutputType init, 
59                          BinaryFunction1 binary_op1,
60                          BinaryFunction2 binary_op2)
61 {
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()
65
66
67 template <typename InputIterator1, typename InputIterator2, typename OutputType>
68 OutputType 
69 inner_product(InputIterator1 first1, InputIterator1 last1,
70               InputIterator2 first2, OutputType init)
71 {
72   using thrust::system::detail::generic::select_system;
73
74   typedef typename thrust::iterator_system<InputIterator1>::type System1;
75   typedef typename thrust::iterator_system<InputIterator2>::type System2;
76
77   System1 system1;
78   System2 system2;
79
80   return thrust::inner_product(select_system(system1,system2), first1, last1, first2, init);
81 } // end inner_product()
82
83
84 template <typename InputIterator1, typename InputIterator2, typename OutputType,
85           typename BinaryFunction1, typename BinaryFunction2>
86 OutputType
87 inner_product(InputIterator1 first1, InputIterator1 last1,
88               InputIterator2 first2, OutputType init, 
89               BinaryFunction1 binary_op1, BinaryFunction2 binary_op2)
90 {
91   using thrust::system::detail::generic::select_system;
92
93   typedef typename thrust::iterator_system<InputIterator1>::type System1;
94   typedef typename thrust::iterator_system<InputIterator2>::type System2;
95
96   System1 system1;
97   System2 system2;
98
99   return thrust::inner_product(select_system(system1,system2), first1, last1, first2, init, binary_op1, binary_op2);
100 } // end inner_product()
101
102
103 } // end namespace thrust
104