Wed, 15 Dec 2021 01:09:09 +0200
Implement ZipArrays
######################### # Some utility functions ######################### __precompile__() module Util ############## # Our exports ############## export map_first_slice!, reduce_first_slice, ⬿ ############################### # For working with NamedTuples ############################### ⬿ = merge ###### # map ###### @inline function map_first_slice!(f!, y) for i in CartesianIndices(size(y)[2:end]) @inbounds f!(@view(y[:, i])) end end @inline function map_first_slice!(x, f!, y) for i in CartesianIndices(size(y)[2:end]) @inbounds f!(@view(x[:, i]), @view(y[:, i])) end end @inline function reduce_first_slice(f, y; init=0.0) accum=init for i in CartesianIndices(size(y)[2:end]) @inbounds accum=f(accum, @view(y[:, i])) end return accum end end # Module