|
45 | 45 | initarray!(a::AbstractArray{T}, f, ::Union{typeof(min),typeof(max),typeof(_extrema_rf)},
|
46 | 46 | init::Bool, src::AbstractArray) where {T} = (init && mapfirst!(f, a, src); a)
|
47 | 47 |
|
48 |
| -for (Op, initval) in ((:(typeof(&)), true), (:(typeof(|)), false)) |
| 48 | +for (Op, initval) in ((:(typeof(and_all)), true), (:(typeof(or_any)), false)) |
49 | 49 | @eval initarray!(a::AbstractArray, ::Any, ::$(Op), init::Bool, src::AbstractArray) = (init && fill!(a, $initval); a)
|
50 | 50 | end
|
51 | 51 |
|
|
173 | 173 | reducedim_init(f::Union{typeof(abs),typeof(abs2)}, op::typeof(max), A::AbstractArray{T}, region) where {T} =
|
174 | 174 | reducedim_initarray(A, region, zero(f(zero(T))), _realtype(f, T))
|
175 | 175 |
|
| 176 | +reducedim_init(f, op::typeof(and_all), A::AbstractArrayOrBroadcasted, region) = reducedim_initarray(A, region, true) |
| 177 | +reducedim_init(f, op::typeof(or_any), A::AbstractArrayOrBroadcasted, region) = reducedim_initarray(A, region, false) |
| 178 | + |
| 179 | +# These definitions are wrong in general; Cf. JuliaLang/julia#45562 |
176 | 180 | reducedim_init(f, op::typeof(&), A::AbstractArrayOrBroadcasted, region) = reducedim_initarray(A, region, true)
|
177 | 181 | reducedim_init(f, op::typeof(|), A::AbstractArrayOrBroadcasted, region) = reducedim_initarray(A, region, false)
|
178 | 182 |
|
@@ -883,13 +887,13 @@ julia> A = [true false; true false]
|
883 | 887 | 1 0
|
884 | 888 | 1 0
|
885 | 889 |
|
886 |
| -julia> all!([1; 1], A) |
887 |
| -2-element Vector{Int64}: |
| 890 | +julia> all!(Bool[1; 1], A) |
| 891 | +2-element Vector{Bool}: |
888 | 892 | 0
|
889 | 893 | 0
|
890 | 894 |
|
891 |
| -julia> all!([1 1], A) |
892 |
| -1×2 Matrix{Int64}: |
| 895 | +julia> all!(Bool[1 1], A) |
| 896 | +1×2 Matrix{Bool}: |
893 | 897 | 1 0
|
894 | 898 | ```
|
895 | 899 | """
|
@@ -958,13 +962,13 @@ julia> A = [true false; true false]
|
958 | 962 | 1 0
|
959 | 963 | 1 0
|
960 | 964 |
|
961 |
| -julia> any!([1; 1], A) |
962 |
| -2-element Vector{Int64}: |
| 965 | +julia> any!(Bool[1; 1], A) |
| 966 | +2-element Vector{Bool}: |
963 | 967 | 1
|
964 | 968 | 1
|
965 | 969 |
|
966 |
| -julia> any!([1 1], A) |
967 |
| -1×2 Matrix{Int64}: |
| 970 | +julia> any!(Bool[1 1], A) |
| 971 | +1×2 Matrix{Bool}: |
968 | 972 | 1 0
|
969 | 973 | ```
|
970 | 974 | """
|
@@ -994,7 +998,7 @@ _all(a, ::Colon) = _all(identity, a, :)
|
994 | 998 |
|
995 | 999 | for (fname, op) in [(:sum, :add_sum), (:prod, :mul_prod),
|
996 | 1000 | (:maximum, :max), (:minimum, :min),
|
997 |
| - (:all, :&), (:any, :|), |
| 1001 | + (:all, :and_all), (:any, :or_any), |
998 | 1002 | (:extrema, :_extrema_rf)]
|
999 | 1003 | fname! = Symbol(fname, '!')
|
1000 | 1004 | _fname = Symbol('_', fname)
|
|
0 commit comments