Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3126 committed Oct 14, 2016
1 parent e335fe0 commit bb91c00
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,10 @@ end
end
end

cummax{T}(A::AbstractArray{T}, axis::Integer=1) = scan(max, A, axis)
cummax(A::AbstractArray, axis::Integer=1) = scan(max, A, axis)
cummax!(B, A, axis::Integer) = scan!(max, B, A, axis)

cummin{T}(A::AbstractArray{T}, axis::Integer=1) = scan(min, A, axis)
cummin(A::AbstractArray, axis::Integer=1) = scan(min, A, axis)
cummin!(B, A, axis::Integer) = scan!(min, B, A, axis)

"""
Expand All @@ -509,7 +509,7 @@ julia> cumsum(a,2)
4 9 15
```
"""
cumsum{T}(A::AbstractArray{T}, axis::Integer=1) = scan(+, A, axis)
cumsum(A::AbstractArray, axis::Integer=1) = scan(+, A, axis)
cumsum!(B, A, axis::Integer) = scan!(+, B, A, axis)

"""
Expand Down Expand Up @@ -573,18 +573,18 @@ function scan(op, A, axis::Integer=1)
scan!(op, out, A, axis)
end

function scan!(op, out, v::AbstractVector, axis::Integer=1)
function scan!(op, B, A::AbstractVector, axis::Integer=1)
axis > 0 || throw(ArgumentError("axis must be a positive integer"))
size(out) == size(v) || throw(DimensionMismatch("shape of out must match v"))
isempty(v) && return out
axis > 1 && return copy!(out, v)
cur_val = v[1]
out[1] = cur_val
@inbounds for i in 2:length(v)
cur_val = op(v[i], cur_val)
out[i] = cur_val
size(B) == size(A) || throw(DimensionMismatch("shape of B must match A"))
isempty(A) && return B
axis > 1 && return copy!(B, A)
cur_val = A[1]
B[1] = cur_val
@inbounds for i in 2:length(A)
cur_val = op(A[i], cur_val)
B[i] = cur_val
end
return out
return B
end

"""
Expand Down

0 comments on commit bb91c00

Please sign in to comment.