function net_=ms2sngPrec(net)
% net_=ms2sngPrec(net)
% turn network net into a single precision network

net_=net;
if strcmp(net.type,'glm2')
if ~isempty(net.TpcaY)
  if ~isempty(net.outMean)
    net_.outMean=single(net_.outMean(:,net.y1Idx)+net.b1*net.TpcaY(:,net.y1Idx));
  else
    net_.outMean=single(net.b1*net.TpcaY(:,net.y1Idx));
  end
  net_.w1=single(net.w1*net.TpcaY(:,net_.y1Idx));
  net_.TpcaY=single(1);
  net_.y1Idx=logical(ones(size(net_.outMean)));
  net_.b1=zeros(1,size(net_.w1,2),'single');
  net_.doOutDeMean=1;net_.doOutPCA=0;net.doPostProc=1;
else
%  net_.outMean=net_.outMean(:,net.y1Idx);
  net_.w1=single(net.w1(:,net_.y1Idx));
  net_.b1=single(net.b1(:,net_.y1Idx));
  net_.y1Idx=logical(ones(size(net_.b1)));
end
end

if sum(strcmp(net.type,{'ffn','ffn2'}))
if ~isempty(net.TpcaY)
  if ~isempty(net.outMean)
    net_.outMean=single(net_.outMean(:,net.y1Idx)+net.b2*net.TpcaY(:,net.y1Idx));
  else
    net_.outMean=single(net.b2*net.TpcaY(:,net.y1Idx));
  end
  net_.w2=single(net.w2*net.TpcaY(:,net_.y1Idx));
  net_.TpcaY=single(1);
  net_.y1Idx=logical(ones(size(net_.outMean)));
  net_.b2=zeros(1,size(net_.w2,2),'single');
  net_.doOutDeMean=1;net_.doOutPCA=0;net.doPostProc=1;
else
  if ~isempty(net.outMean)
    net_.outMean=net_.outMean(:,net.y1Idx);
  end
  net_.w2=single(net.w2(:,net_.y1Idx));
  net_.b2=single(net.b2(:,net_.y1Idx));
  net_.y1Idx=logical(ones(size(net_.b1)));
end
end

if strcmp(net.type,'mxTime')
  if ~isempty(net.TpcaY);
    net_.TpcaY=single(net.TpcaY(:,net.y1Idx));
  else
    for i=1:length(net.Uk)
      net_.Uk{i}.w1=single(net.Uk{i}.w1(:,net.y1Idx));
      net_.Uk{i}.b1=single(net.Uk{i}.b1(:,net.y1Idx));
    end
  end
  if ~isempty(net.outMean);net_.outMean=single(net.outMean(:,net.y1Idx));end
  net_.y1Idx=true(sum(net_.y1Idx),1);
end
