function F = mkfactor(U,X)
% MKFACTOR Generate a factor from the discriminant and a feature
%
% F = MKFACTOR(U,X)

% LINFACTORDISCR.MKFACTOR
    
  T = get(U.factordiscr,'template'); 
  
  if T ~= get(X,'template')
	error('Factor template mismatch');
  end;
  
  % xxx *sigh* this copy (get feature) is going to slow the whole thing down

  E = U.weights * get(X,'feature');
  
  if ~isempty(U.bias)
	E = E + U.bias;
  end;
  
  D = card(T);
  
  if isscalar(D)
	D = [D  1];
  end;
  
  E = reshape(E,D);
  
  F = factor( get(X,'variables'),E);
  
  
