view arrows/ufold.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 672052bd81f8
children
line wrap: on
line source
% ufold - Fold data into processing unit
%
% ufold :: 
%    unit({[[N,1]]}, _, S) ~'live processing unit',
%    [[N,T]]               ~'data to pass through',
%    S                     ~'initial state of unit',
%    options {
%       draw  :: boolean/false ~'whether or not to call drawnow after each iteration';
%       quiet :: boolean/false ~'whether or not to suppress progress messages'
%    } 
% -> S                     ~'final state'.
%
% This function accepts the live processing unit associated
% with an arrow (as created by with_arrow). The arrow must
% accept one column vector as input. Its output is ignored.
% The state of the unit is first set, then data is passed
% through one column at a time, and the final state is returned.

function A2=ufold(unit,X,A1,varargin)
	if ~isempty(A1), unit.set_state(A1); end
	uiter(unit,size(X,2),@foldx,[],'label','ufold',varargin{:});
	A2=unit.get_state();

	function s=foldx(i,s), unit.process(X(:,i)); end
end