function [nfirst,h,classl,ncl] = classes(G,multab,inel)
%
% The group element indices of class I are put into classl(nfirst(I)) to
% classl(nfirst(I) + h(I) - 1). Within the class, these numbers are in
% increasing order. h(I) is the order of class I. ncl is the number of
% classes for the group.
h(1) = 1;
classl(1) = 1;
ncl = 1;
nfirst(1) = 1;
if G > 1
NT = 2;
L = 2;
ncl = 2;
while L <= G
h(ncl) = 1;
N2 = L;
classl(NT) = L;
nfirst(ncl) = NT;
for M = 1:G
L1 = multab(M,L);
M1 = inel(M);
KL(M) = multab(L1,M1);
end
for M = 1:G
for I = 1:G
if KL(I) == N2
KL(I) = 0;
end
end
if KL(M) ~= 0
NT = NT + 1;
h(ncl) = h(ncl) + 1;
%
% A new class element is registered. The other KL(I), equal to this one,
% are skipped.
%
N2 = KL(M);
classl(NT) = N2;
end
end
%
% NT is equal to the total number of elements that have been registered
% in classl so far.
%
N = nfirst(ncl);
if N <= NT
for I = N:NT
I1 = I + 1;
if I1 <= NT
for J = I1:NT
if classl(I) > classl(J)
NIP = classl(J);
classl(J) = classl(I);
classl(I) = NIP;
end
end
end
end
end
L = L + 1;
I = 2;
while I <= NT
if L == classl(I)
L = L + 1;
I = 1;
end
I = I + 1;
end
if L <= G
ncl = ncl + 1;
NT = NT + 1;
end
end
end
return