function w = mixpak(net)
%mixpak	Combines weights and biases of a mixtures of experts model into one weight vector.
%
%	Description
%	W = MIXPAK(NET) takes a mixture of experts data structure NET and 
%       combines the component weight matrices and bias vectors into a single 
%       row vector W. The facility to switch between these two
%       representations for the network parameters is useful, for example,
%       in training mixtures of experts by error function minimization,
%       since a single vector of parameters can be handled by
%       general-purpose optimization routines. 
%
%       See also
%       glmpak, mix, mixunpak, mixfwd, mixerr, mixgrad
%
%       Copyright: Perry Moerland

% Check arguments for consistency
errstring = consist(net, 'mix');
if ~isempty(errstring);
  error(errstring);
end

w = [];

for i=1:net.nexp
  % expert network is GLM
  temp = glmpak(net.exp(i));
  w = cat(2,w,temp);
end;

% gating network is GLM
temp = glmpak(net.gate);
w = cat(2,w,temp);
 
