Skip to content

Commit

Permalink
Document that reduce may exploit commutativity
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 25, 2020
1 parent 35c1f87 commit 51c3485
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ In general, it will be necessary to provide `init` to work with empty collection
intermediate collection needs to be created. See documentation for [`reduce`](@ref) and
[`map`](@ref).
Known commutativity of the operation `op` such as `+` and `max` may be exploited in the
implementation. It means that the elements of `itr` may be accessed out of order and
the order in which `f` is called is implementation-defined.
!!! compat "Julia 1.2"
`mapreduce` with multiple iterators requires Julia 1.2 or later.
Expand Down Expand Up @@ -440,6 +444,9 @@ use non-associative operations like `-` because it is undefined whether `reduce(
should be evaluated as `(1-2)-3` or `1-(2-3)`. Use [`foldl`](@ref) or
[`foldr`](@ref) instead for guaranteed left or right associativity.
Known commutativity of the operation `op` such as `+` and `max` may be exploited in the
implementation. It means that the elements of `itr` may be accessed out of order.
Some operations accumulate error. Parallelism will be easier if the reduction can be
executed in groups. Future versions of Julia might change the algorithm. Note that the
elements are not reordered if you use an ordered collection.
Expand Down

0 comments on commit 51c3485

Please sign in to comment.