Reverse
AcceleratedKernels.reverse! — Function
reverse!(
v::AbstractArray;
backend=nothing,
dims=:,
block_size::Int=256,
max_tasks::Int=Threads.nthreads(),
min_elems::Int=1,
) -> vReverse v in-place and return it. With dims=: (the default) the whole array is reversed; pass dims=d (an integer or an iterable of distinct integers in 1:ndims(v)) to reverse only along those dimensions. dims=() leaves v unchanged. backend is derived from v; the other keywords are those of foreachindex.
No temporary array is allocated.
To reverse a contiguous sub-range of a vector, reverse a view: AK.reverse!(@view v[lo:hi]).
Examples
import CUDAimport AcceleratedKernels as AKv = CUDA.CuArray(1:100_000)AK.reverse!(v)m = CUDA.CuArray(reshape(1:12, 3, 4))AK.reverse!(m; dims=2) # reverse the columnsreverse!(
dst::AbstractArray, src::AbstractArray;
backend=nothing,
dims=:,
block_size::Int=256,
max_tasks::Int=Threads.nthreads(),
min_elems::Int=1,
) -> dstWrite the reverse of src into dst and return dst; src is left unchanged. dst must not overlap src (an ArgumentError). With dims=: (the default), the whole array is reversed and only the lengths must match; with an integer or iterable of distinct dimensions, the sizes must match (else a DimensionMismatch). dims=() copies src unchanged. Elements are converted to the destination element type on assignment. backend is derived from dst and src; the other keywords are those of foreachindex.
AcceleratedKernels.reverse — Function
reverse(v::AbstractArray; kwargs...)Return a reversed copy of v, leaving v unchanged. With dims=: (the default) the whole array is reversed; pass dims=d to reverse only along those dimensions, matching Base.reverse. The keywords are those of reverse!.
Prefer reverse! when you do not need to keep v; it avoids the allocation.