function U = linfactordiscr(varargin)
% LINFACTORDISCR Linear discriminant factor
%
% U = LINFACTORDISCR(T,M) where T is a factor template and M is the
% number of features
%
% U = LINFACTORDISCR(T,M,B) where B indicates to include a bias
% feature
%
% U = LINFACTORDISCR Creates an empty/default object
%
% U = LINFACTORDISCR(A) where A is a linfactordiscr object will return a
% copy of A
  
% Fields
%  weights
%  bias
  
  if nargin == 0
	
	U0 = factordiscr();
	
	U.weights = [];
	U.bias = [];
	
	U = class(U,'linfactordiscr',U0);
	
  elseif nargin == 1 && isa(varargin{1},'linfactordiscr')
	
	U = varargin{1};
	
  else
	
	T = varargin{1};
	M = varargin{2};
	
	if nargin<3
	  B = 1;
	else
	  B = varargin{3};
	end;
	
	if ~isscalar(M)
	  error('M must be a scalar');
	end;
	
	if ~isscalar(B)
	  error('B must be a scalar');
	end;
	
	U0 = factordiscr(T);
	
	
	U.weights = zeros([prod(card(T)) M]);

	if B
	  U.bias = zeros([prod(card(T)) 1]);
	else
	  U.bias = [];
	end;

	U = class(U,'linfactordiscr',U0);
	
  end;
