This version completely avoids allocations, but is roughly the same speed:
function baz!(G)
for slice in eachslice(G; dims=(3, 5))
slice .*= sqrt(sum(abs2, slice))
end
return G
end
This version completely avoids allocations, but is roughly the same speed:
function baz!(G)
for slice in eachslice(G; dims=(3, 5))
slice .*= sqrt(sum(abs2, slice))
end
return G
end