function M1 = compact_names(M0) % a technical routine to make sure that the states are numbered % from 1 to length(M.Q) ft = fsa_type(M0); switch ft case 'd' M1 = compact_names_d(M0); case 'n' M1 = compact_names_n(M0); end return function M1 = compact_names_d(M0) % the deterministic version Q0 = M0.Q; nQ = length(Q0); Q1 = 1:nQ; M1 = M0; M1.Q = Q1; M1.q0 = news(M0.q0,Q0); %M1.qd = news(M0.qd,Q0); M1.F = []; for q = M0.F M1.F(end+1) = news(q,Q0); end M1 = init_ddelta(M1); for q0=Q0 [qq1,ss1] = get_ddelta(M0,q0); for j=1:length(qq1) M1 = set_ddelta(M1,news(q0,Q0),ss1(j),news(qq1(j),Q0)); end end return function M1 = compact_names_n(M0) % the non-deterministic version Q0 = M0.Q; nQ = length(Q0); Q1 = 1:nQ; M1 = M0; M1.Q = Q1; M1.q0 = news(M0.q0,Q0); M1.F = []; for q = M0.F M1.F(end+1) = news(q,Q0); end M1 = init_ndelta(M1); for q0=Q0 for s=M1.ALF R = nfsa_delta(M0,q0,s); for j=1:length(R) R(j) = news(R(j),Q0); end M1 = set_ndelta(M1,[news(q0,Q0)],[s],{R}); end end return function q1 = news(q0,Q0) q1 = find(Q0==q0); return