hpx/parallel/container_algorithms/transform_reduce.hpp#

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx

Functions

template<typename ExPolicy, typename Iter, typename Sent, typename T, typename Reduce, typename Convert>
hpx::parallel::util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Iter first, Sent last, T init, Reduce &&red_op, Convert &&conv_op)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Iter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

  • Sent – The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

  • Reduce – The type of the binary function object used for the reduction operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • first – Refers to the beginning of the first sorted range the algorithm will be applied to.

  • last – Refers to the end of the second sorted range the algorithm will be applied to.

  • init – The initial value for the generalized sum.

  • red_op – Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

    R fun(const Type &a);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type Iter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

Returns

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type parallel_task_policy and returns T otherwise. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename Iter, typename Sent, typename T, typename Reduce, typename Convert>
T transform_reduce(Iter first, Sent last, T init, Reduce &&red_op, Convert &&conv_op)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • Iter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

  • Sent – The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

  • Reduce – The type of the binary function object used for the reduction operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • first – Refers to the beginning of the first sorted range the algorithm will be applied to.

  • last – Refers to the end of the second sorted range the algorithm will be applied to.

  • init – The initial value for the generalized sum.

  • red_op – Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

    R fun(const Type &a);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type Iter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

Returns

The transform_reduce algorithm returns T. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename ExPolicy, typename Iter, typename Sent, typename Iter2, typename T>
hpx::parallel::util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Iter first, Sent last, Iter2 first2, T init)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Iter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

  • Sent – The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • Iter2 – The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an random access iterator.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • first – Refers to the beginning of the first sorted range the algorithm will be applied to.

  • last – Refers to the end of the second sorted range the algorithm will be applied to.

  • first2 – Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

  • init – The initial value for the generalized sum.

Returns

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type parallel_task_policy and returns T otherwise. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename Iter, typename Sent, typename Iter2, typename T>
T transform_reduce(Iter first, Sent last, Iter2 first2, T init)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • Iter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

  • Sent – The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • Iter2 – The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an random access iterator.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

Parameters
  • first – Refers to the beginning of the first sorted range the algorithm will be applied to.

  • last – Refers to the end of the second sorted range the algorithm will be applied to.

  • first2 – Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

  • init – The initial value for the generalized sum.

Returns

The transform_reduce algorithm returns T. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename ExPolicy, typename Iter, typename Sent, typename Iter2, typename T, typename Reduce, typename Convert>
hpx::parallel::util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Iter first, Sent last, Iter2 first2, T init, Reduce &&red_op, Convert &&conv_op)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Iter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

  • Sent – The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • Iter2 – The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an random access iterator.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

  • Reduce – The type of the binary function object used for the reduction operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • first – Refers to the beginning of the first sorted range the algorithm will be applied to.

  • last – Refers to the end of the second sorted range the algorithm will be applied to.

  • first2 – Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

  • init – The initial value for the generalized sum.

  • red_op – Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

    R fun(const Type &a);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type Iter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

Returns

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type parallel_task_policy and returns T otherwise. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename Iter, typename Sent, typename Iter2, typename T, typename Reduce, typename Convert>
T transform_reduce(Iter first, Sent last, Iter2 first2, T init, Reduce &&red_op, Convert &&conv_op)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • Iter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an random access iterator.

  • Sent – The type of the end source iterators used (deduced). This iterator type must meet the requirements of an sentinel for Iter.

  • Iter2 – The type of the source iterators used (deduced) representing the second sequence. This iterator type must meet the requirements of an random access iterator.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

  • Reduce – The type of the binary function object used for the reduction operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • first – Refers to the beginning of the first sorted range the algorithm will be applied to.

  • last – Refers to the end of the second sorted range the algorithm will be applied to.

  • first2 – Refers to the beginning of the sequence of elements of the second range the algorithm will be applied to.

  • init – The initial value for the generalized sum.

  • red_op – Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

    R fun(const Type &a);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type Iter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

Returns

The transform_reduce algorithm returns T. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename ExPolicy, typename Rng, typename T, typename Reduce, typename Convert>
hpx::parallel::util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Rng &&rng, T init, Reduce &&red_op, Convert &&conv_op)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The reduce operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

  • Reduce – The type of the binary function object used for the reduction operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • init – The initial value for the generalized sum.

  • red_op – Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

    R fun(const Type &a);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type Iter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

Returns

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type parallel_task_policy and returns T otherwise. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename Rng, typename T, typename Reduce, typename Convert>
T transform_reduce(Rng &&rng, T init, Reduce &&red_op, Convert &&conv_op)#

Returns GENERALIZED_SUM(red_op, init, conv_op(*first), …, conv_op(*(first + (last - first) - 1))).

The difference between transform_reduce and accumulate is that the behavior of transform_reduce may be non-deterministic for non-associative or non-commutative binary predicate.

Note

Complexity: O(last - first) applications of the predicates red_op and conv_op.

Note

GENERALIZED_SUM(op, a1, …, aN) is defined as follows:

  • a1 when N is 1

  • op(GENERALIZED_SUM(op, b1, …, bK), GENERALIZED_SUM(op, bM, …, bN)), where:

    • b1, …, bN may be any permutation of a1, …, aN and

    • 1 < K+1 = M <= N.

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • T – The type of the value to be used as initial (and intermediate) values (deduced).

  • Reduce – The type of the binary function object used for the reduction operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • init – The initial value for the generalized sum.

  • red_op – Specifies the function (or function object) which will be invoked for each of the values returned from the invocation of conv_op. This is a binary predicate. The signature of this predicate should be equivalent to:

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1, Type2, and Ret must be such that an object of a type as returned from conv_op can be implicitly converted to any of those types.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is a unary predicate. The signature of this predicate should be equivalent to:

    R fun(const Type &a);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type Iter can be dereferenced and then implicitly converted to Type. The type R must be such that an object of this type can be implicitly converted to T.

Returns

The transform_reduce algorithm returns T. The transform_reduce algorithm returns the result of the generalized sum over the values returned from conv_op when applied to the elements given by the input range [first, last).

template<typename ExPolicy, typename Rng, typename Iter2, typename T>
hpx::parallel::util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Rng &&rng, Iter2 first2, T init)#

Returns the result of accumulating init with the inner products of the pairs formed by the elements of two ranges starting at first1 and first2.

The operations in the parallel transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note

Complexity: O(last - first) applications of the predicate op2.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter2 – The type of the second source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • T – The type of the value to be used as return) values (deduced).

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • first2 – Refers to the beginning of the second sequence of elements the result will be calculated with.

  • init – The initial value for the sum.

Returns

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise.

template<typename Rng, typename Iter2, typename T>
T transform_reduce(Rng &&rng, Iter2 first2, T init)#

Returns the result of accumulating init with the inner products of the pairs formed by the elements of two ranges starting at first1 and first2.

Note

Complexity: O(last - first) applications of the predicate op2.

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter2 – The type of the second source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • T – The type of the value to be used as return) values (deduced).

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • first2 – Refers to the beginning of the second sequence of elements the result will be calculated with.

  • init – The initial value for the sum.

Returns

The transform_reduce algorithm returns T.

template<typename ExPolicy, typename Rng, typename Iter2, typename T, typename Reduce, typename Convert>
hpx::parallel::util::detail::algorithm_result<ExPolicy, T>::type transform_reduce(ExPolicy &&policy, Rng &&rng, Iter2 first2, T init, Reduce &&red_op, Convert &&conv_op)#

Returns the result of accumulating init with the inner products of the pairs formed by the elements of two ranges starting at first1 and first2.

The operations in the parallel transform_reduce algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The operations in the parallel transform_reduce algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note

Complexity: O(last - first) applications of the predicate op2.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter2 – The type of the second source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • T – The type of the value to be used as return) values (deduced).

  • Reduce – The type of the binary function object used for the multiplication operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • first2 – Refers to the beginning of the second sequence of elements the result will be calculated with.

  • init – The initial value for the sum.

  • red_op – Specifies the function (or function object) which will be invoked for the initial value and each of the return values of op2. This is a binary predicate. The signature of this predicate should be equivalent to should be equivalent to:

    Ret fun(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Ret must be such that it can be implicitly converted to a type of T.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the input values of the sequence. This is a binary predicate. The signature of this predicate should be equivalent to

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Ret must be such that it can be implicitly converted to an object for the second argument type of op1.

Returns

The transform_reduce algorithm returns a hpx::future<T> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns T otherwise.

template<typename Rng, typename Iter2, typename T, typename Reduce, typename Convert>
T transform_reduce(Rng &&rng, Iter2 first2, T init, Reduce &&red_op, Convert &&conv_op)#

Returns the result of accumulating init with the inner products of the pairs formed by the elements of two ranges starting at first1 and first2.

Note

Complexity: O(last - first) applications of the predicate op2.

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an input iterator.

  • Iter2 – The type of the second source iterators used (deduced). This iterator type must meet the requirements of an forward iterator.

  • T – The type of the value to be used as return) values (deduced).

  • Reduce – The type of the binary function object used for the multiplication operation.

  • Convert – The type of the unary function object used to transform the elements of the input sequence before invoking the reduce function.

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • first2 – Refers to the beginning of the second sequence of elements the result will be calculated with.

  • init – The initial value for the sum.

  • red_op – Specifies the function (or function object) which will be invoked for the initial value and each of the return values of op2. This is a binary predicate. The signature of this predicate should be equivalent to should be equivalent to:

    Ret fun(const Type1 &a, const Type1 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Ret must be such that it can be implicitly converted to a type of T.

  • conv_op – Specifies the function (or function object) which will be invoked for each of the input values of the sequence. This is a binary predicate. The signature of this predicate should be equivalent to

    Ret fun(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Ret must be such that it can be implicitly converted to an object for the second argument type of op1.

Returns

The transform_reduce algorithm returns T.