Mercurial > hg > ishara
diff arrows/@loop/construct.m @ 0:672052bd81f8
Initial partial import.
author | samer |
---|---|
date | Wed, 19 Dec 2012 22:38:28 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arrows/@loop/construct.m Wed Dec 19 22:38:28 2012 +0000 @@ -0,0 +1,18 @@ +function u=construct(s,sizes_in) + u=mkunit(s); + state=s.s0(sizes_in{1}); fn=s.fn; + u.sizes_out = guess_sizes(fn,sizes_in,state); + u.get_state = @get_state; + u.set_state = @set_state; + u.process = @proc; + + function out=proc(in), [out,state]=fn(in,state); end + function s=get_state, s=state; end + function set_state(s), state=s; end +end + +function sz_out=guess_sizes(fn,sz_in,st) + [out,s1] = fn(zeros(sz_in{1}),st); + sz_out = {size(out)}; +end +