matrix kex_diff( void)
{
/*
 * compute relative norms of the differences between the paths
 */
  matrix r = zeros(L,L);
  int el1, el2, j, k;
  double d, dmin;
  vector perm, i1, i2;

  for( el1=1; el1<=L; ++el1) {
    for( el2=el1+1; el2<=L; ++el2) {
      dmin = HUGE_VAL;
      for( k=1; k<=MP; ++k) {
	d = 0;
	perm = perms(k);
        for( j=1; j<=K; ++j) {
	  i1 = 1 + ((el1-1)*K + (j-1))*2;
	  i1 = [i1:i1+1];
	  i2 = 1 + ((el2-1)*K + (perm(j)-1))*2;
	  i2 = [i2:i2+1];
	  d += norm( kex(:,i1) - kex(:,i2));
        }
	if( d < dmin) dmin = d;
      }
    r(el1,el2) = dmin;
    }
  }

  return r/(norm(kex(:,1:2*K))/100);
}
