You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,8 @@ Library improvements
60
60
you can now do e.g. `[A I]` and it will concatenate an appropriately sized
61
61
identity matrix ([#19305]).
62
62
63
+
* New `accumulate` and `accumulate!` functions, which generalize `cumsum` and `cumprod`. Also known as a [scan](https://en.wikipedia.org/wiki/Prefix_sum) operation ([#18931]).
64
+
63
65
Compiler/Runtime improvements
64
66
-----------------------------
65
67
@@ -76,6 +78,8 @@ Deprecated or removed
76
78
77
79
*`Dates.recur` has been deprecated in favor of `filter` ([#19288])
78
80
81
+
*`cummin` and `cummax` have been deprecated in favor of `accumulate`.
Copy file name to clipboardExpand all lines: doc/stdlib/arrays.rst
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1499,6 +1499,32 @@ Indexing, Assignment, and Concatenation
1499
1499
Array functions
1500
1500
---------------
1501
1501
1502
+
.. function:: accumulate(op, A, dim=1)
1503
+
1504
+
.. Docstring generated from Julia source
1505
+
1506
+
Cumulative operation ``op`` along a dimension ``dim`` (defaults to 1). See also :func:`accumulate!` to use a preallocated output array, both for performance and to control the precision of the output (e.g. to avoid overflow). For common operations there are specialized variants of accumulate, see: :func:`cumsum`\ , :func:`cumprod`
1507
+
1508
+
.. doctest::
1509
+
1510
+
julia> accumulate(+, [1,2,3])
1511
+
3-element Array{Int64,1}:
1512
+
1
1513
+
3
1514
+
6
1515
+
1516
+
julia> accumulate(*, [1,2,3])
1517
+
3-element Array{Int64,1}:
1518
+
1
1519
+
2
1520
+
6
1521
+
1522
+
.. function:: accumulate!(op, B, A, dim=1)
1523
+
1524
+
.. Docstring generated from Julia source
1525
+
1526
+
Cumulative operation ``op`` on ``A`` along a dimension, storing the result in ``B``\ . The dimension defaults to 1. See also :func:`accumulate`\ .
0 commit comments