summaryrefslogtreecommitdiff
path: root/boost/compute/algorithm/exclusive_scan.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:38:45 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:39:52 +0900
commit5cde13f21d36c7224b0e13d11c4b49379ae5210d (patch)
treee8269ac85a4b0f7d416e2565fa4f451b5cb41351 /boost/compute/algorithm/exclusive_scan.hpp
parentd9ec475d945d3035377a0d89ed42e382d8988891 (diff)
downloadboost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.gz
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.bz2
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.zip
Imported Upstream version 1.61.0
Change-Id: I96a1f878d1e6164f01e9aadd5147f38fca448d90 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/compute/algorithm/exclusive_scan.hpp')
-rw-r--r--boost/compute/algorithm/exclusive_scan.hpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/boost/compute/algorithm/exclusive_scan.hpp b/boost/compute/algorithm/exclusive_scan.hpp
new file mode 100644
index 0000000000..205d3de658
--- /dev/null
+++ b/boost/compute/algorithm/exclusive_scan.hpp
@@ -0,0 +1,96 @@
+//---------------------------------------------------------------------------//
+// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
+//
+// Distributed under the Boost Software License, Version 1.0
+// See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+//
+// See http://boostorg.github.com/compute for more information.
+//---------------------------------------------------------------------------//
+
+#ifndef BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP
+#define BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP
+
+#include <boost/compute/functional.hpp>
+#include <boost/compute/system.hpp>
+#include <boost/compute/command_queue.hpp>
+#include <boost/compute/algorithm/detail/scan.hpp>
+
+namespace boost {
+namespace compute {
+
+/// Performs an exclusive scan of the elements in the range [\p first, \p last)
+/// and stores the results in the range beginning at \p result.
+///
+/// Each element in the output is assigned to the sum of all the previous
+/// values in the input.
+///
+/// \param first first element in the range to scan
+/// \param last last element in the range to scan
+/// \param result first element in the result range
+/// \param init value used to initialize the scan sequence
+/// \param binary_op associative binary operator
+/// \param queue command queue to perform the operation
+///
+/// \return \c OutputIterator to the end of the result range
+///
+/// The default operation is to add the elements up.
+///
+/// \snippet test/test_scan.cpp exclusive_scan_int
+///
+/// But different associative operation can be specified as \p binary_op
+/// instead (e.g., multiplication, maximum, minimum). Also value used to
+/// initialized the scan sequence can be specified.
+///
+/// \snippet test/test_scan.cpp exclusive_scan_int_multiplies
+///
+/// \see inclusive_scan()
+template<class InputIterator, class OutputIterator, class T, class BinaryOperator>
+inline OutputIterator
+exclusive_scan(InputIterator first,
+ InputIterator last,
+ OutputIterator result,
+ T init,
+ BinaryOperator binary_op,
+ command_queue &queue = system::default_queue())
+{
+ return detail::scan(first, last, result, true, init, binary_op, queue);
+}
+
+/// \overload
+template<class InputIterator, class OutputIterator, class T>
+inline OutputIterator
+exclusive_scan(InputIterator first,
+ InputIterator last,
+ OutputIterator result,
+ T init,
+ command_queue &queue = system::default_queue())
+{
+ typedef typename
+ std::iterator_traits<OutputIterator>::value_type output_type;
+
+ return detail::scan(first, last, result, true,
+ init, boost::compute::plus<output_type>(),
+ queue);
+}
+
+/// \overload
+template<class InputIterator, class OutputIterator>
+inline OutputIterator
+exclusive_scan(InputIterator first,
+ InputIterator last,
+ OutputIterator result,
+ command_queue &queue = system::default_queue())
+{
+ typedef typename
+ std::iterator_traits<OutputIterator>::value_type output_type;
+
+ return detail::scan(first, last, result, true,
+ output_type(0), boost::compute::plus<output_type>(),
+ queue);
+}
+
+} // end compute namespace
+} // end boost namespace
+
+#endif // BOOST_COMPUTE_ALGORITHM_EXCLUSIVE_SCAN_HPP