@@ -731,15 +731,6 @@ julia> findn(A)
731
731
end
732
732
733
733
734
- # see discussion in #18364 ... we try not to widen type of the resulting array
735
- # from cumsum or cumprod, but in some cases (+, Bool) we may not have a choice.
736
- rcum_promote_type (op, :: Type{T} , :: Type{S} ) where {T,S} = promote_op (op, T, S)
737
- rcum_promote_type (op, :: Type{T} ) where {T} = rcum_promote_type (op, T,T)
738
-
739
- # handle sums of Vector{Bool} and similar. it would be nice to handle
740
- # any AbstractArray here, but it's not clear how that would be possible
741
- rcum_promote_type (op, :: Type{Array{T,N}} ) where {T,N} = Array{rcum_promote_type (op,T), N}
742
-
743
734
# accumulate_pairwise slightly slower then accumulate, but more numerically
744
735
# stable in certain situations (e.g. sums).
745
736
# it does double the number of operations compared to accumulate,
@@ -773,7 +764,7 @@ function accumulate_pairwise!(op::Op, result::AbstractVector, v::AbstractVector)
773
764
end
774
765
775
766
function accumulate_pairwise (op, v:: AbstractVector{T} ) where T
776
- out = similar (v, rcum_promote_type (op, T))
767
+ out = similar (v, promote_op (op, T))
777
768
return accumulate_pairwise! (op, out, v)
778
769
end
779
770
@@ -818,7 +809,7 @@ julia> cumsum(a,2)
818
809
```
819
810
"""
820
811
function cumsum (A:: AbstractArray{T} , dim:: Integer ) where T
821
- out = similar (A, rcum_promote_type (+ , T))
812
+ out = similar (A, promote_op (+ , T))
822
813
cumsum! (out, A, dim)
823
814
end
824
815
@@ -952,7 +943,7 @@ julia> accumulate(+, fill(1, 3, 3), 2)
952
943
```
953
944
"""
954
945
function accumulate (op, A, dim:: Integer )
955
- out = similar (A, rcum_promote_type (op, eltype (A)))
946
+ out = similar (A, promote_op (op, eltype (A)))
956
947
accumulate! (op, out, A, dim)
957
948
end
958
949
@@ -1101,7 +1092,7 @@ julia> accumulate(min, 0, [1,2,-1])
1101
1092
```
1102
1093
"""
1103
1094
function accumulate (op, v0, x:: AbstractVector )
1104
- T = rcum_promote_type (op, typeof (v0), eltype (x))
1095
+ T = promote_op (op, typeof (v0), eltype (x))
1105
1096
out = similar (x, T)
1106
1097
accumulate! (op, out, v0, x)
1107
1098
end
0 commit comments