1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #define BOOST_TEST_MODULE TestInnerProduct
12 #include <boost/test/unit_test.hpp>
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/inner_product.hpp>
16 #include <boost/compute/container/vector.hpp>
17 #include <boost/compute/iterator/counting_iterator.hpp>
19 #include "context_setup.hpp"
21 namespace bc
= boost::compute
;
23 BOOST_AUTO_TEST_CASE(inner_product_int
)
25 int data1
[] = { 1, 2, 3, 4 };
26 bc::vector
<int> input1(data1
, data1
+ 4, queue
);
28 int data2
[] = { 10, 20, 30, 40 };
29 bc::vector
<int> input2(data2
, data2
+ 4, queue
);
31 int product
= bc::inner_product(input1
.begin(),
36 BOOST_CHECK_EQUAL(product
, 300);
39 BOOST_AUTO_TEST_CASE(inner_product_counting_iterator
)
42 boost::compute::inner_product(
43 boost::compute::make_counting_iterator
<int>(0),
44 boost::compute::make_counting_iterator
<int>(100),
45 boost::compute::make_counting_iterator
<int>(0),
53 BOOST_AUTO_TEST_SUITE_END()