Wed, 22 Dec 2021 11:14:38 +0200
Add metaprogramming tools and fast multidimensional loops.
######################### # 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