function [loopl,lpstr,numl] = permu(multab,G,steer,inel,IN)
%
% This subroutine determines the loop-structure of the element IN,
% considered as the permutation of G elements.
% numl = number of loops
% loopl(K) = lengh of Kth loop
% lpstr(K) = loopstructure, parentheses omitted.
%
fid = fopen('Irrepres.m', 'a');
K = inel(IN);
numl = 0;
flip = zeros(1,G);
L1 = 1;
LT = 1;
for K1 = 1:G
  if flip(K1) ~= 1
    flip(K1) = 1;
    K2 = K1;
    lpstr(LT) = K2;
    N = multab(K,K2);
    while N ~= K1
      LT = LT + 1;
      L1 = L1 + 1;
      lpstr(LT) = N;
      flip(N) = 1;
      K2 = N;
      N = multab(K,K2);
    end
    numl = numl + 1;
    loopl(numl) = L1;
    if LT == G
      break;
    end
    LT = LT + 1;
    L1 = 1;
  end
end
if steer(4)
  fprintf(fid, 'Loopstructure of group element %3d\n', IN);
  fprintf(fid, '\n');
  fprintf(fid, 'Loopstructure:\n');
  fprintf(fid, '\n');
  fprintf(fid, '%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n', lpstr(1:G));
  fprintf(fid, '\n');
  fprintf(fid, 'Looplength:\n');
  fprintf(fid, '\n');
  fprintf(fid, '%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n', loopl(1:numl));
  fprintf(fid, '\n');
end
fclose(fid);
return