image thumbnail
from Eckart Inertias by Bryan Wong
A suite of MATLAB codes to calculate effective Eckart inertias for internal rotation

[gaussian_matrix,permutations]=permutation(gaussian_matrix,symmetry)
function [gaussian_matrix,permutations]=permutation(gaussian_matrix,symmetry)

if symmetry > 1

    permutations=1;

    N=length(gaussian_matrix(:,1,1));

    trials=length(gaussian_matrix(1,1,:));

    gaussian_matrix(:,:,trials+1:2*trials-2)=gaussian_matrix(:,:,linspace(trials-1,2,trials-2));
    gaussian_matrix(:,2,trials+1:2*trials-2)=-gaussian_matrix(:,2,trials+1:2*trials-2);

    reflected_gaussian_matrix=gaussian_matrix(:,:,trials);
    reflected_gaussian_matrix(:,2,:)=-reflected_gaussian_matrix(:,2,:);

    for i=1:N

        diff_gaussian_matrix=ones(N,1)*reflected_gaussian_matrix(i,:,:)-gaussian_matrix(:,:,trials);

        [min_diff,min_index_column(i,1)]=min(sum(diff_gaussian_matrix.^2,2));

    end

    gaussian_matrix(:,:,trials+1:2*trials-2)=gaussian_matrix(min_index_column,:,trials+1:2*trials-2);

    for i=1:N

        diff_gaussian_matrix=ones(N,1)*gaussian_matrix(i,:,end)-gaussian_matrix(:,:,1);

        [min_diff,min_index_column(i,1)]=min(sum(diff_gaussian_matrix.^2,2));

    end

    while sum(min_index_column==[1:N]')~=N

        permutations=permutations+1;

        gaussian_matrix(:,:,end+1:end+1+2*trials-3)=gaussian_matrix(min_index_column,:,1:2*trials-2);

        for i=1:N

            diff_gaussian_matrix=ones(N,1)*gaussian_matrix(i,:,end)-gaussian_matrix(:,:,1);

            [min_diff,min_index_column(i,1)]=min(sum(diff_gaussian_matrix.^2,2));

        end

    end

else

    permutations=0;

end

Contact us at files@mathworks.com