samer@0
|
1 function u=construct(s,sizes_in)
|
samer@0
|
2 nout=nargout(s);
|
samer@0
|
3 u=mkunit(s);
|
samer@0
|
4 h=s.h(sizes_in);
|
samer@0
|
5
|
samer@0
|
6 procs = { @proc00, @proc01, @proc0n; ...
|
samer@0
|
7 @proc10, @proc11, @proc11; ...
|
samer@0
|
8 @procn0, @procn1, @procnn };
|
samer@0
|
9
|
samer@0
|
10 u.sizes_out = s.sizefn(sizes_in);
|
samer@0
|
11 u.process = procs{ n2i(nargin(s)), n2i(nargout(s)) };
|
samer@0
|
12 u.dispose = @()release(h);
|
samer@0
|
13
|
samer@0
|
14 function i=n2i(n), i=1+max(n,2); end
|
samer@0
|
15 function proc00(in), step(h); end
|
samer@0
|
16 function proc10(in), step(h,in); end
|
samer@0
|
17 function proc01(in), out=step(h); end
|
samer@0
|
18 function out=proc11(in), out=step(h,in); end
|
samer@0
|
19
|
samer@0
|
20 function procn0(varargin), step(h,varargin{:}); end
|
samer@0
|
21 function out=procn1(varargin), out=step(h,varargin{:}); end
|
samer@0
|
22 function varargout=proc0n, [varargout{1:nout}]=step(h); end
|
samer@0
|
23 function varargout=proc1n(in), [varargout{1:nout}]=step(h,in); end
|
samer@0
|
24
|
samer@0
|
25 function varargout=procnn(varargin), [varargout{1:nout}]=step(h,varargin{:}); end
|
samer@0
|
26 end
|
samer@0
|
27
|