]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_inner_product.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_inner_product.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
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
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #define BOOST_TEST_MODULE TestInnerProduct
12 #include <boost/test/unit_test.hpp>
13
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>
18
19 #include "context_setup.hpp"
20
21 namespace bc = boost::compute;
22
23 BOOST_AUTO_TEST_CASE(inner_product_int)
24 {
25 int data1[] = { 1, 2, 3, 4 };
26 bc::vector<int> input1(data1, data1 + 4, queue);
27
28 int data2[] = { 10, 20, 30, 40 };
29 bc::vector<int> input2(data2, data2 + 4, queue);
30
31 int product = bc::inner_product(input1.begin(),
32 input1.end(),
33 input2.begin(),
34 0,
35 queue);
36 BOOST_CHECK_EQUAL(product, 300);
37 }
38
39 BOOST_AUTO_TEST_CASE(inner_product_counting_iterator)
40 {
41 BOOST_CHECK_EQUAL(
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),
46 0,
47 queue
48 ),
49 328350
50 );
51 }
52
53 BOOST_AUTO_TEST_SUITE_END()