void get_x( void) 
{
/*
 * data setup for symbol values (-1,-1), (-1,1), (1,-1), (1,1)
 * with f(D) = f0 + f1 * D + f2 * D * D
 * KB ECE 8770 Spring 1998 Lecture 11 page 11
 */

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

    KALMAN=0;   /* don't use Kalman cost function */

  states = FSM( [-1 1], 2);

  zstate = 1;			/* zero state, states( zstate) == (-1,-1) */

  x = [ -1 1 1 -1 -1];		/* input sequence */

  /* x = 2 * rand( 1, N, "int", 2) - 3; */

  f = [ 0.2 -0.4 0.6]';

  trans = FSM_trans( states, f);	/* get state transition matrix */

  y = FSM_out( x, states, zstate, f);	/* get FSM output */

  /*
  y = f(1) * x
    + f(2) * [ states(zstate,1) x(1:N-1)]
    + f(3) * [ states(zstate,1) states(zstate,2) x(1:N-2)];
  */

  n = [-0.043256     -0.16656     0.012533     0.028768     -0.11465];

  /* n = 0.1 * rand( 1, N, "gauss");	/* random noise */

  z = y + n;			/* signal plus noise */
}


double get_yval( int _cur, int _next)
{
  return trans( _cur, _next);
}


double get_cost( double _zz, int _cur, int _next, int _j)
{
  double yval = get_yval( _cur, _next);

  if( yval == HUGE_VAL)
    return yval;

  return pn( _zz - yval);
}

vector get_ex( vector _index)
{
  vector t = states(:,1)';

  return t( _index);
}
