@@ -243,143 +243,6 @@ end
243
243
end
244
244
245
245
# ###############
246
- # function vvextrema_nonzip(f::F, initmin::Iₘᵢₙ, initmax::Iₘₐₓ, A::AbstractArray{T, N}, dims::NTuple{M, Int}) where {F, Iₘᵢₙ, Iₘₐₓ, T, N, M}
247
- # Dᴬ = size(A)
248
- # Dᴮ = ntuple(d -> d ∈ dims ? 1 : Dᴬ[d], Val(N))
249
- # Tₒ = Base.promote_op(f, T)
250
- # B = similar(A, Tuple{Tₒ, Tₒ}, Dᴮ)
251
- # _vvextrema_nonzip!(f, initmin, initmax, B, A, dims)
252
- # return B
253
- # end
254
-
255
- # function staticdim_extrema_nonzip_quote(Iₘᵢₙ, Iₘₐₓ, static_dims::Vector{Int}, N::Int)
256
- # A = Expr(:ref, :A, ntuple(d -> Symbol(:i_, d), N)...)
257
- # Bᵥ = Expr(:call, :view, :B)
258
- # Bᵥ′ = Expr(:ref, :Bᵥ)
259
- # rinds = Int[]
260
- # nrinds = Int[]
261
- # for d = 1:N
262
- # if d ∈ static_dims
263
- # push!(Bᵥ.args, Expr(:call, :firstindex, :B, d))
264
- # push!(rinds, d)
265
- # else
266
- # push!(Bᵥ.args, :)
267
- # push!(nrinds, d)
268
- # push!(Bᵥ′.args, Symbol(:i_, d))
269
- # end
270
- # end
271
- # reverse!(rinds)
272
- # reverse!(nrinds)
273
- # if !isempty(nrinds)
274
- # block = Expr(:block)
275
- # loops = Expr(:for, :($(Symbol(:i_, nrinds[1])) = indices((A, B), $(nrinds[1]))), block)
276
- # for d ∈ @view(nrinds[2:end])
277
- # newblock = Expr(:block)
278
- # push!(block.args, Expr(:for, :($(Symbol(:i_, d)) = indices((A, B), $d)), newblock))
279
- # block = newblock
280
- # end
281
- # rblock = block
282
- # # Pre-reduction
283
- # mn = Expr(:(=), :mn, Expr(:call, Symbol(Iₘᵢₙ.instance), Expr(:call, :eltype, Expr(:call, :eltype, :Bᵥ))))
284
- # mx = Expr(:(=), :mx, Expr(:call, Symbol(Iₘₐₓ.instance), Expr(:call, :eltype, Expr(:call, :eltype, :Bᵥ))))
285
- # push!(rblock.args, mn, mx)
286
- # # Reduction loop alt
287
- # newblock = Expr(:block)
288
- # d = first(rinds)
289
- # il1 = Expr(:for, :($(Symbol(:i_, d)) = axes(A, $d)), newblock)
290
- # push!(block.args, :(@turbo $il1))
291
- # # push!(block.args, quote @turbo $il1 end)
292
- # block = newblock
293
- # for d ∈ @view(rinds[2:end])
294
- # newblock = Expr(:block)
295
- # push!(block.args, Expr(:for, :($(Symbol(:i_, d)) = axes(A, $d)), newblock))
296
- # block = newblock
297
- # end
298
- # # Push to inside innermost loop
299
- # setmin = Expr(:(=), :mn, Expr(:call, :min, Expr(:call, :f, A), :mn))
300
- # setmax = Expr(:(=), :mx, Expr(:call, :max, Expr(:call, :f, A), :mx))
301
- # push!(block.args, setmin, setmax)
302
- # setb = Expr(:(=), Bᵥ′, Expr(:tuple, :mn, :mx))
303
- # push!(rblock.args, setb)
304
- # return quote
305
- # Bᵥ = $Bᵥ
306
- # $loops
307
- # return B
308
- # end
309
- # else
310
- # # Pre-reduction
311
- # mn = Expr(:(=), :mn, Expr(:call, Symbol(Iₘᵢₙ.instance), Expr(:call, :eltype, Expr(:call, :eltype, :Bᵥ))))
312
- # mx = Expr(:(=), :mx, Expr(:call, Symbol(Iₘₐₓ.instance), Expr(:call, :eltype, Expr(:call, :eltype, :Bᵥ))))
313
- # # Reduction loop
314
- # block = Expr(:block)
315
- # loops = Expr(:for, :($(Symbol(:i_, rinds[1])) = axes(A, $(rinds[1]))), block)
316
- # for d ∈ @view(rinds[2:end])
317
- # newblock = Expr(:block)
318
- # push!(block.args, Expr(:for, :($(Symbol(:i_, d)) = axes(A, $d)), newblock))
319
- # block = newblock
320
- # end
321
- # # Push to inside innermost loop
322
- # setmin = Expr(:(=), :mn, Expr(:call, :min, Expr(:call, :f, A), :mn))
323
- # setmax = Expr(:(=), :mx, Expr(:call, :max, Expr(:call, :f, A), :mx))
324
- # push!(block.args, setmin, setmax)
325
- # return quote
326
- # Bᵥ = $Bᵥ
327
- # $mn
328
- # $mx
329
- # @turbo $loops
330
- # Bᵥ[] = (mn, mx)
331
- # return B
332
- # end
333
- # end
334
- # end
335
-
336
- # function branches_extrema_nonzip_quote(Iₘᵢₙ, Iₘₐₓ, N::Int, M::Int, D)
337
- # static_dims = Int[]
338
- # for m ∈ 1:M
339
- # param = D.parameters[m]
340
- # if param <: StaticInt
341
- # new_dim = _dim(param)::Int
342
- # push!(static_dims, new_dim)
343
- # else
344
- # # tuple of static dimensions
345
- # t = Expr(:tuple)
346
- # for n ∈ static_dims
347
- # push!(t.args, :(StaticInt{$n}()))
348
- # end
349
- # q = Expr(:block, :(dimm = dims[$m]))
350
- # qold = q
351
- # # if-elseif statements
352
- # ifsym = :if
353
- # for n ∈ 1:N
354
- # n ∈ static_dims && continue
355
- # tc = copy(t)
356
- # push!(tc.args, :(StaticInt{$n}()))
357
- # qnew = Expr(ifsym, :(dimm == $n), :(return _vvextrema_nonzip!(f, initmin, initmax, B, A, $tc)))
358
- # for r ∈ m+1:M
359
- # push!(tc.args, :(dims[$r]))
360
- # end
361
- # push!(qold.args, qnew)
362
- # qold = qnew
363
- # ifsym = :elseif
364
- # end
365
- # # else statement
366
- # tc = copy(t)
367
- # for r ∈ m+1:M
368
- # push!(tc.args, :(dims[$r]))
369
- # end
370
- # push!(qold.args, Expr(:block, :(return _vvextrema_nonzip!(f, initmin, initmax, B, A, $tc))))
371
- # return q
372
- # end
373
- # end
374
- # return staticdim_extrema_nonzip_quote(Iₘᵢₙ, Iₘₐₓ, static_dims, N)
375
- # end
376
-
377
-
378
- # @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}}}
379
- # branches_extrema_nonzip_quote(Iₘᵢₙ, Iₘₐₓ, N, M, D)
380
- # end
381
-
382
- # ###########################################################################################
383
246
# Version wherein an initial value is supplied
384
247
function vvextrema (f:: F , initmin:: Iₘ ᵢₙ, initmax:: Iₘₐₓ , A:: AbstractArray{T, N} , :: Colon ) where {F, Iₘᵢₙ<: Number , Iₘₐₓ<: Number , T, N}
385
248
Tₒ = Base. promote_op (f, T)
0 commit comments