1 function success = test_affine_decomp(fct,nargout,params_pos,varargin)
2 %
function success = test_affine_decomp(fct,nargout,params_pos,varargin)
4 %
function calling the
function given by handle fct with the
5 % arguments varargin and expecting nargout many output arguments.
6 % The fct is called with the
'varargin{params_pos}.decomp_mode' set to 1,2 and
7 % linear combination is performed and checked,
if result is
8 % identical to the
'complete' mode
'decomp_mode =0'.
13 % [A1, A2, A3] = my_fct(params,data)
19 % test_affine_decomp(@my_fct,3,1,params,data);
22 % where params.decomp_mode is expected to be 0.
24 % Bernard Haasdonk 7.9.2009
26 if varargin{params_pos}.decomp_mode ~=0
27 error(
'please call this routine only in decomp_mode == 0 modus!');
30 var_complete = cell(1,nargout);
31 %[var_complete{1:nargout}]= fct(params,varargin{:});
32 [var_complete{1:nargout}]= fct(varargin{:});
34 varargin{params_pos}.decomp_mode = 2;
35 %params.decomp_mode = 2;
36 var_coefficients = cell(1,nargout);
37 [var_coefficients{1:nargout}]= fct(varargin{:});
39 %params.decomp_mode = 1;
40 varargin{params_pos}.decomp_mode = 1;
41 var_components = cell(1,nargout);
42 [var_components{1:nargout}]= fct(varargin{:});
44 var_assembled = cell(1,nargout);
45 err = zeros(1,nargout);
48 if isempty(var_components{q})
49 if ~isempty(var_coefficients{q})
50 error(
'components empty but not coefficients!!');
53 var_assembled{q} = lincomb_sequence(var_components{q},var_coefficients{q});
54 err(q) = max(abs(var_assembled{q}(:) - var_complete{q}(:)));
56 error(['error in affine decomposition of return argument ',...