% utransfer - Run a processing unit, passing data through and collecting outputs
%
% utransfer :: 
%    unit({[[N,1]]}, {[[M,1]]}, _) ~'live processing unit',
%    [[N,T]]                       ~'data to pass through',
%    options {
%       draw  :: boolean/false ~'whether or not to call drawnow after each iteration';
%       quiet :: boolean/false ~'whether or not to suppress progress messages'
%    } 
% -> [[M,T]] ~'collected output'.
%
% This function accepts the live processing unit associated
% with an arrow (as created by with_arrow). The arrow must
% have zero inputs and one output. The requested number of outputs
% are collected into an array and returned. If inf outputs are
% requested, the system is run until an EOF exception is caught.

function Y=utransfer(u,X,varargin)
	Y=zeros(u.sizes_out{1}(1),size(X,2));
	uiter(u,size(X,2),@transferx,[],'label','utransfer',varargin{:});

	function s=transferx(i,s), Y(:,i)=u.process(X(:,i)); end
end
