function d=dist(x,y) // calcule les distances 2 a 2 // x est une matrice mx * n // y est une matrice my * n // renvoit une matrice d = dist(x(i,:),y(j,:)) [mx,n]=size(x) [my,n]=size(y) d = 0*ones(mx,my) for i=1:mx d1= sum( abs(y - ones(my,1)* x(i,:)),'c') d(i,:) = d1' end endfunction x=int(2*rand(10,2)) d=dist(x,x) function steps=stepeval(x,y) // x and y are row vectors // d is the distance between x,y // try to compute a suite of transformations // leading from x to y [mx,n]=size(x) Inds = find( x<>y) nsteps= size(Inds,'*')-1 steps = ones(nsteps,n) steps(1,:)=x(:)'; steps(1,Inds(1))=bool2s(~steps(1,Inds(1))); for i = 2:nsteps steps(i,:)= steps(i-1,:); steps(i,Inds(i))=bool2s(~steps(i-1,Inds(i))); end endfunction