Mercurial > hg > ishara
view arrows/@arr/arr.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | beb8a3f4a345 |
children |
line wrap: on
line source
% arr - Lift function to processing unit % % arr :: % F:(A@typelist(N)->B@typelist(M)) ~'arbitrary function with N inputs and M outputs', % options { % nargin :: natural / nargin(F); % nargout :: natural / nargout(F); % } % -> arrow(A@typelist(N),B@typelist(M),empty). % % The arr class is a class of arrows which simply apply an ordinary % Matlab function to the inputs to obtain the outputs. In many cases, % the number of inputs and outputs can be determined from the supplied % function handle, but if the number arguments in or out is variable, % then the nargin and nargout options must be used. % % The type empty denotes the type of empty arrays, ie % the state of an arr arrow is always an empty matrix. % % arr(@log) - arrow which supplies the log of its input. % arr(@plus) - sum two inputs to produce output % arr(@(a,b)deal(a+b,a-b),'nargout',2) - computes sum and difference of inputs. function o=arr(fn,varargin) if nargin==0, fn=@id; end opts=options('nargin',[],'nargout',[],'sizefn',[],varargin{:}); if isempty(opts.nargin), opts.nargin=nargin(fn); end if isempty(opts.nargout), opts.nargout=nargout(fn); end if opts.nargout<0, opts.nargout=1; end % assume 1 if we can't tell o=class(struct('fn',fn,'sizefn',opts.sizefn),'arr',arrow(opts.nargin,opts.nargout)); end