Performance optimization:Frequently use permutedims function

Corrected several typos:

function a(G)
    G = permutedims(G,[1,2,4,3,5]);
    k = sqrt.(sum(abs2.(reshape(G,589824,1,1,14,6)),dims = 1));
    G .*= k;
    G = permutedims(G,[1,2,4,3,5]);
end

function b(G)
    G = PermutedDimsArray(G,[1,2,4,3,5]);
    G .*= sqrt.(sum(abs2, reshape(G,589824,1,1,14,6),dims = 1));
    G = PermutedDimsArray(G,[1,2,4,3,5]);
end

function baz!(G)
    for slice in eachslice(G; dims=(3, 5))
        slice .*= sqrt.(sum(abs2, slice))
    end
    return G
end
1 Like

No dot is needed after sqrt since its argument is a scalar. Actually, adding a dot might cause a slowdown.

sorry, my bad. I modified here after I encountered the error message (actually caused by the former functions) without further thought.