cumsum_kbn

cumsum_kbn(A, [dim])

Cumulative sum along a dimension, using the Kahan-Babuska-Neumaier compensated summation algorithm for additional accuracy. The dimension defaults to 1.

Examples

julia> A = [1, 2, 3, 4];
julia> cumsum_kbn(A)
4-element Array{Int64,1}:
  1
  3
  6
 10
julia> B = [1 2 3; 4 5 6; 7 8 9];
julia> cumsum_kbn(B, 2)
3×3 Array{Int64,2}:
  1   3   6
  4   9  15
  7  15  24
julia> C = [1.0, 0.1, 0.01, 0.001];
julia> cumsum_kbn(C)
4-element Array{Float64,1}:
 1.0
 1.1
 1.11
 1.111

Common mistake example:

julia> D = ["a", "b", "c"];
julia> cumsum_kbn(D)
ERROR: MethodError: no method matching cumsum_kbn(::Array{String,1})

In this example, the cumsum_kbn function cannot be applied to an array of strings. Make sure the input array consists of numerical values.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: