Home > atmlab > handy > cached_evaluation.m

cached_evaluation

PURPOSE ^

Wrapper around CachedData.evaluate

SYNOPSIS ^

function varargout = cached_evaluation(func, varargin)

DESCRIPTION ^

 Wrapper around CachedData.evaluate

 Using a persistent 1 GiB cached object, evaluate and cache expressions.

   [out1, out2, ...] = cached_evaluation(@func, in1, in2, ...)

 is equivalent to

   [out1, out2, ...] = func(in1, in2, ...)

 except that the results are cached.

 For more information, see CachedData/evaluate.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

cached_evaluation.m

SOURCE CODE ^

0001 function varargout = cached_evaluation(func, varargin)
0002 
0003 % Wrapper around CachedData.evaluate
0004 %
0005 % Using a persistent 1 GiB cached object, evaluate and cache expressions.
0006 %
0007 %   [out1, out2, ...] = cached_evaluation(@func, in1, in2, ...)
0008 %
0009 % is equivalent to
0010 %
0011 %   [out1, out2, ...] = func(in1, in2, ...)
0012 %
0013 % except that the results are cached.
0014 %
0015 % For more information, see CachedData/evaluate.
0016 
0017 persistent cd
0018 
0019 if isequal(cd, [])
0020     cd = CachedData();
0021     cd.maxsize = 2.^30; % 1 GiB
0022 end
0023 
0024 nout = nargout;
0025 [varargout{1:nout}] = cd.evaluate(nout, func, varargin{:});
0026 
0027 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005