function vec = simple_mlp_cell2vec(W,rmaj)
% Wraps weight matrices into a 1d vector form (for general optimization
% code). Order of vec: b1 W1colMaj b2 W2colMaj ...

rowmajor = (nargin==2) && ischar(rmaj) && strcmp(rmaj, 'row');

vec = [];
for L = 1:length(W)
  if rowmajor
    vec = [vec ; reshape(W{L}',numel(W{L}'),1)];
  else % ..it is column major (default)
    vec = [vec ; reshape(W{L},numel(W{L}),1)];
  end
end
