用法:
accumulate(op, A; dims::Integer, [init])沿 A 的维度 dims 的累积运算 op(提供 dims 对于向量是可选的)。初始值init 可以选择由关键字参数提供。另请参阅  以使用预分配的输出数组,以提高性能和控制输出的精度(例如,避免溢出)。对于常见操作,有 accumulate! accumulate 的特殊变体,请参阅: 、cumsum  cumprod 
Julia 1.5
非数组迭代器上的accumulate 至少需要 Julia 1.5。
例子
julia> accumulate(+, [1,2,3])
3-element Vector{Int64}:
 1
 3
 6
julia> accumulate(*, [1,2,3])
3-element Vector{Int64}:
 1
 2
 6
julia> accumulate(+, [1,2,3]; init=100)
3-element Vector{Int64}:
 101
 103
 106
julia> accumulate(min, [1,2,-1]; init=0)
3-element Vector{Int64}:
  0
  0
 -1
julia> accumulate(+, fill(1, 3, 3), dims=1)
3×3 Matrix{Int64}:
 1  1  1
 2  2  2
 3  3  3
julia> accumulate(+, fill(1, 3, 3), dims=2)
3×3 Matrix{Int64}:
 1  2  3
 1  2  3
 1  2  3相关用法
- Julia accumulate!用法及代码示例
- Julia acos方法用法及代码示例
- Julia any!用法及代码示例
- Julia all方法用法及代码示例
- Julia any方法用法及代码示例
- Julia argmin用法及代码示例
- Julia angle用法及代码示例
- Julia axes()用法及代码示例
- Julia abs用法及代码示例
- Julia all!用法及代码示例
- Julia abs2用法及代码示例
- Julia adjoint用法及代码示例
- Julia allunique用法及代码示例
- Julia append!用法及代码示例
- Julia abs()用法及代码示例
- Julia abs2()用法及代码示例
- Julia axes方法用法及代码示例
- Julia atan方法用法及代码示例
- Julia ascii用法及代码示例
- Julia argmax用法及代码示例
- Julia asin方法用法及代码示例
- Julia splice!用法及代码示例
- Julia @cfunction用法及代码示例
- Julia LibGit2.count用法及代码示例
- Julia LinearAlgebra.BLAS.dot用法及代码示例
注:本文由纯净天空筛选整理自julialang.org 大神的英文原创作品 Base.accumulate — Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
