0001 function RM= calc_TSVD_RM(mdl,hp)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if ischar(mdl) && strcmp(mdl, 'UNIT_TEST'), do_unit_test, return,end
0017
0018
0019
0020 switch (mdl.type)
0021 case 'inv_model'
0022 fmdl = mdl.fwd_model;
0023 bkgnd_img = calc_jacobian_bkgnd(mdl);
0024 case 'fwd_model'
0025 fmdl = mdl;
0026 bkgnd_img = mk_image( fmdl,1) ;
0027 otherwise
0028 eidors_msg('calc_TSVD_RM: Object type not supported');
0029 end
0030
0031 if nargin < 2
0032 hp = .1;
0033 end
0034 J= calc_jacobian(bkgnd_img);
0035 copt.fstr = 'calc_TSVD_RM';
0036 RM = eidors_cache(@calc_RM,{J, hp}, copt);
0037
0038 function RM = calc_RM(J, hp)
0039
0040 imdl.solve = @solve_use_matrix;
0041 copt.cache_obj = J;
0042 copt.fstr = 'svd';
0043
0044 [U,S,V] = eidors_cache(@svd,{J, 'econ'},copt);
0045
0046 s = diag(S);
0047 s = s./s(1);
0048 N = find(s >= hp/100,1,'last');
0049 t= 1:N;
0050 RM = (V(:,t)/S(t,t))*U(:,t)';
0051
0052
0053
0054 function do_unit_test
0055 mdl = mk_common_model('b3t2r',[16,1]);
0056 RM = calc_TSVD_RM(mdl);
0057 J = calc_jacobian(mk_image(mdl));
0058 unit_test_cmp('RM size', size(RM), size(J'));
0059
0060