/* IO(1) */

load x9_10;

/*
 * tracks where L-list viterbi does not produce the optimal path when L=1
 */

void get_x( int _K)
{
/* data setup for simple x/y/velocity targets */

  int i, j;
  vector jj;
  matrix ppp;
  int M_clutter;

  if( narg == 0) {

    LOADED=11;

    N = 3;	/* N data samples */
    M = 2;	/* M symbol values */
    K = 1;	/* find K best completely unmerged paths */

    MM = M;	/* save original M, used when K > 1 */

/*** note: dt is global and is used in get_cost() below ***/

    dt = 1;
     t = [0:N-1];


  xv = [	0  1  2  0
		0  3  0 -3
		1  2  0  0
		10 10 0  0
		1  0  0  0
		10 10 0  0
];

   Kn = 0.01;	/* measurement noise variance */

if(0)
   xv += sqrt(Kn) * rand( rows(xv), cols(xv), "gauss");

/* randomize the observation rows */

if(0) {
    ppp = permutations(1:M);

    for( i = 1; i <= N; ++i) {
      j = 1 + (i-1) * M;
      jj = [j:j+M-1];
      xv(jj) = xv( jj( ppp( rand(1,1,"int",M))));
    }
}

    zstate = 0;

    z = zeros(1,N);	/* dummy */

    return;
  }

  /* narg > 0 */

  if( LOADED != 11) {
    print( "get_x: call get_x with no args first.");
    return;
  }

  if( _K > MM) {
    printf( "get_x: K > M not allowed!");
    return;
  }

  K = _K;

  setup_combos(); /* setup global variables: perms, combos, unique_perms, MP, and M */

  zstate = 0;
}
