Skip to content

Commit 9933142

Browse files
Rename to match vv convention
1 parent 6526a84 commit 9933142

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/vextrema.jl

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
############################################################################################
77
# interface
88
"""
9-
vextrema([f=identity], A::AbstractArray; [dims=:], [init=(mn,mx)])
9+
vvextrema([f=identity], A::AbstractArray; [dims=:], [init=(mn,mx)])
1010
1111
Compute the minimum and maximum values by calling `f` on each element of of `A`
1212
over the given `dims`, with the `mn` and `mx` initialized by the respective arguments
@@ -25,44 +25,44 @@ julia> A = reshape(Vector(1:2:16), (2,2,2))
2525
9 13
2626
11 15
2727
28-
julia> vextrema(abs2, A, dims=(1,2), init=(typemax, 100))
28+
julia> vvextrema(abs2, A, dims=(1,2), init=(typemax, 100))
2929
1×1×2 Array{Tuple{Int64, Int64}, 3}:
3030
[:, :, 1] =
3131
(1, 100)
3232
3333
[:, :, 2] =
3434
(81, 225)
3535
36-
julia> vextrema(abs2, A, init=(typemax, 100))
36+
julia> vvextrema(abs2, A, init=(typemax, 100))
3737
(1, 225)
3838
```
3939
"""
40-
vextrema(f, A; dims=:, init=(typemax, typemin)) = vextrema(f, init[1], init[2], A, dims)
41-
vextrema(A; dims=:, init=(typemax, typemin)) = vextrema(identity, init[1], init[2], A, dims)
40+
vvextrema(f, A; dims=:, init=(typemax, typemin)) = vvextrema(f, init[1], init[2], A, dims)
41+
vvextrema(A; dims=:, init=(typemax, typemin)) = vvextrema(identity, init[1], init[2], A, dims)
4242

4343
# handle convenience cases
44-
vextrema(f, initmin, initmax, A, dims::Int) = vextrema(f, initmin, initmax, A, (dims,))
44+
vvextrema(f, initmin, initmax, A, dims::Int) = vvextrema(f, initmin, initmax, A, (dims,))
4545

4646
"""
47-
vextrema([f=identity], A::AbstractArray, dims=:)
47+
vvextrema([f=identity], A::AbstractArray, dims=:)
4848
4949
Compute the minimum and maximum values by calling `f` on each element of of `A`
5050
over the given `dims`.
5151
"""
52-
vextrema(f, A, dims) = vextrema(f, typemax, typemin, A, dims)
53-
vextrema(A::AbstractArray, dims) = vextrema(identity, A, dims)
52+
vvextrema(f, A, dims) = vvextrema(f, typemax, typemin, A, dims)
53+
vvextrema(A::AbstractArray, dims) = vvextrema(identity, A, dims)
5454

5555
# support any kind of init args -- this necessitates Iₘᵢₙ<:Function, Iₘₐₓ<:Function
5656
# for the function-initialized version. It would be nice to support functors, but
5757
# LoopVectorization would likely throw anyway.
58-
vextrema(f, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A, dims) where {Iₘᵢₙ<:Function, Iₘₐₓ<:Number} =
59-
vextrema(f, initmin(Base.promote_op(f, eltype(A))), initmax, A, dims)
60-
vextrema(f, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A, dims) where {Iₘᵢₙ<:Number, Iₘₐₓ<:Function} =
61-
vextrema(f, initmin, initmax(Base.promote_op(f, eltype(A))), A, dims)
58+
vvextrema(f, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A, dims) where {Iₘᵢₙ<:Function, Iₘₐₓ<:Number} =
59+
vvextrema(f, initmin(Base.promote_op(f, eltype(A))), initmax, A, dims)
60+
vvextrema(f, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A, dims) where {Iₘᵢₙ<:Number, Iₘₐₓ<:Function} =
61+
vvextrema(f, initmin, initmax(Base.promote_op(f, eltype(A))), A, dims)
6262

6363
################
6464

65-
function vextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, ::Colon) where {F, Iₘᵢₙ<:Function, Iₘₐₓ<:Function, T, N}
65+
function vvextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, ::Colon) where {F, Iₘᵢₙ<:Function, Iₘₐₓ<:Function, T, N}
6666
Tₒ = Base.promote_op(f, T)
6767
mn = initmin(Tₒ)
6868
mx = initmax(Tₒ)
@@ -73,13 +73,13 @@ function vextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArr
7373
mn, mx
7474
end
7575

76-
function vextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ<:Function, Iₘₐₓ<:Function, T, N, M}
76+
function vvextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ<:Function, Iₘₐₓ<:Function, T, N, M}
7777
Dᴬ = size(A)
7878
Dᴮ = ntuple(d -> d dims ? 1 : Dᴬ[d], Val(N))
7979
Tₒ = Base.promote_op(f, T)
8080
B = similar(A, Tₒ, Dᴮ)
8181
C = similar(A, Tₒ, Dᴮ)
82-
_vextrema!(f, initmin, initmax, B, C, A, dims)
82+
_vvextrema!(f, initmin, initmax, B, C, A, dims)
8383
return collect(zip(B, C))
8484
end
8585

@@ -188,7 +188,7 @@ function branches_extrema_quote(Iₘᵢₙ, Iₘₐₓ, N::Int, M::Int, D)
188188
n static_dims && continue
189189
tc = copy(t)
190190
push!(tc.args, :(StaticInt{$n}()))
191-
qnew = Expr(ifsym, :(dimm == $n), :(return _vextrema!(f, initmin, initmax, B, C, A, $tc)))
191+
qnew = Expr(ifsym, :(dimm == $n), :(return _vvextrema!(f, initmin, initmax, B, C, A, $tc)))
192192
for r m+1:M
193193
push!(tc.args, :(dims[$r]))
194194
end
@@ -201,14 +201,14 @@ function branches_extrema_quote(Iₘᵢₙ, Iₘₐₓ, N::Int, M::Int, D)
201201
for r m+1:M
202202
push!(tc.args, :(dims[$r]))
203203
end
204-
push!(qold.args, Expr(:block, :(return _vextrema!(f, initmin, initmax, B, C, A, $tc))))
204+
push!(qold.args, Expr(:block, :(return _vvextrema!(f, initmin, initmax, B, C, A, $tc))))
205205
return q
206206
end
207207
end
208208
return staticdim_extrema_quote(Iₘᵢₙ, Iₘₐₓ, static_dims, N)
209209
end
210210

211-
@generated function _vextrema!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::D) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M, D<:Tuple{Vararg{Integer, M}}}
211+
@generated function _vvextrema!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::D) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M, D<:Tuple{Vararg{Integer, M}}}
212212
branches_extrema_quote(Iₘᵢₙ, Iₘₐₓ, N, M, D)
213213
end
214214

@@ -230,17 +230,17 @@ function extrema_map_quote(Iₘᵢₙ, Iₘₐₓ)
230230
end
231231
end
232232

233-
@generated function _vextrema!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::Tuple{}) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M}
233+
@generated function _vvextrema!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::Tuple{}) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M}
234234
extrema_map_quote(Iₘᵢₙ, Iₘₐₓ)
235235
end
236236

237237
################
238-
# function vextrema_nonzip(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ, Iₘₐₓ, T, N, M}
238+
# function vvextrema_nonzip(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ, Iₘₐₓ, T, N, M}
239239
# Dᴬ = size(A)
240240
# Dᴮ = ntuple(d -> d ∈ dims ? 1 : Dᴬ[d], Val(N))
241241
# Tₒ = Base.promote_op(f, T)
242242
# B = similar(A, Tuple{Tₒ, Tₒ}, Dᴮ)
243-
# _vextrema_nonzip!(f, initmin, initmax, B, A, dims)
243+
# _vvextrema_nonzip!(f, initmin, initmax, B, A, dims)
244244
# return B
245245
# end
246246

@@ -346,7 +346,7 @@ end
346346
# n ∈ static_dims && continue
347347
# tc = copy(t)
348348
# push!(tc.args, :(StaticInt{$n}()))
349-
# qnew = Expr(ifsym, :(dimm == $n), :(return _vextrema_nonzip!(f, initmin, initmax, B, A, $tc)))
349+
# qnew = Expr(ifsym, :(dimm == $n), :(return _vvextrema_nonzip!(f, initmin, initmax, B, A, $tc)))
350350
# for r ∈ m+1:M
351351
# push!(tc.args, :(dims[$r]))
352352
# end
@@ -359,21 +359,21 @@ end
359359
# for r ∈ m+1:M
360360
# push!(tc.args, :(dims[$r]))
361361
# end
362-
# push!(qold.args, Expr(:block, :(return _vextrema_nonzip!(f, initmin, initmax, B, A, $tc))))
362+
# push!(qold.args, Expr(:block, :(return _vvextrema_nonzip!(f, initmin, initmax, B, A, $tc))))
363363
# return q
364364
# end
365365
# end
366366
# return staticdim_extrema_nonzip_quote(Iₘᵢₙ, Iₘₐₓ, static_dims, N)
367367
# end
368368

369369

370-
# @generated function _vextrema_nonzip!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tuple{Tₒ, Tₒ}, N}, A::AbstractArray{T, N}, dims::D) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M, D<:Tuple{Vararg{Integer, M}}}
370+
# @generated function _vvextrema_nonzip!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tuple{Tₒ, Tₒ}, N}, A::AbstractArray{T, N}, dims::D) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M, D<:Tuple{Vararg{Integer, M}}}
371371
# branches_extrema_nonzip_quote(Iₘᵢₙ, Iₘₐₓ, N, M, D)
372372
# end
373373

374374
############################################################################################
375375
# Version wherein an initial value is supplied
376-
function vextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, ::Colon) where {F, Iₘᵢₙ<:Number, Iₘₐₓ<:Number, T, N}
376+
function vvextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, ::Colon) where {F, Iₘᵢₙ<:Number, Iₘₐₓ<:Number, T, N}
377377
Tₒ = Base.promote_op(f, T)
378378
mn = convert(Tₒ, initmin)
379379
mx = convert(Tₒ, initmax)
@@ -384,13 +384,13 @@ function vextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArr
384384
mn, mx
385385
end
386386

387-
function vextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ<:Number, Iₘₐₓ<:Number, T, N, M}
387+
function vvextrema(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ<:Number, Iₘₐₓ<:Number, T, N, M}
388388
Dᴬ = size(A)
389389
Dᴮ = ntuple(d -> d dims ? 1 : Dᴬ[d], Val(N))
390390
Tₒ = Base.promote_op(f, T)
391391
B = similar(A, Tₒ, Dᴮ)
392392
C = similar(A, Tₒ, Dᴮ)
393-
_vextrema_init!(f, initmin, initmax, B, C, A, dims)
393+
_vvextrema_init!(f, initmin, initmax, B, C, A, dims)
394394
return collect(zip(B, C))
395395
end
396396

@@ -503,7 +503,7 @@ function branches_extrema_init_quote(N::Int, M::Int, D)
503503
n static_dims && continue
504504
tc = copy(t)
505505
push!(tc.args, :(StaticInt{$n}()))
506-
qnew = Expr(ifsym, :(dimm == $n), :(return _vextrema_init!(f, initmin, initmax, B, C, A, $tc)))
506+
qnew = Expr(ifsym, :(dimm == $n), :(return _vvextrema_init!(f, initmin, initmax, B, C, A, $tc)))
507507
for r m+1:M
508508
push!(tc.args, :(dims[$r]))
509509
end
@@ -516,15 +516,15 @@ function branches_extrema_init_quote(N::Int, M::Int, D)
516516
for r m+1:M
517517
push!(tc.args, :(dims[$r]))
518518
end
519-
push!(qold.args, Expr(:block, :(return _vextrema_init!(f, initmin, initmax, B, C, A, $tc))))
519+
push!(qold.args, Expr(:block, :(return _vvextrema_init!(f, initmin, initmax, B, C, A, $tc))))
520520
return q
521521
end
522522
end
523523
return staticdim_extrema_init_quote(static_dims, N)
524524
end
525525

526526

527-
@generated function _vextrema_init!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::D) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M, D<:Tuple{Vararg{Integer, M}}}
527+
@generated function _vvextrema_init!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::D) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M, D<:Tuple{Vararg{Integer, M}}}
528528
branches_extrema_init_quote(N, M, D)
529529
end
530530

@@ -546,7 +546,7 @@ function extrema_init_map_quote()
546546
end
547547
end
548548

549-
@generated function _vextrema_init!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::Tuple{}) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M}
549+
@generated function _vvextrema_init!(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, B::AbstractArray{Tₒ, N}, C::AbstractArray{Tₒ, N}, A::AbstractArray{T, N}, dims::Tuple{}) where {F, Iₘᵢₙ, Iₘₐₓ, Tₒ, T, N, M}
550550
extrema_init_map_quote()
551551
end
552552

0 commit comments

Comments
 (0)