R = calc_R_prior( inv_model, varargin ) CALC_R_PRIOR: calculate regularization matrix R The image prior is matrix n_elem x ??? calc_R_prior can be called as R_prior= calc_R_prior( inv_model, ... ) and will call the function inv_model.R_prior parameters to R_prior should be passed in the field inv_model.R_prior_function_name.parameters R_prior calculated regularization prior R inv_model is an inv_model structure
0001 function R_prior = calc_R_prior( inv_model, varargin ) 0002 % R = calc_R_prior( inv_model, varargin ) 0003 % CALC_R_PRIOR: calculate regularization matrix R 0004 % The image prior is matrix n_elem x ??? 0005 % 0006 % calc_R_prior can be called as 0007 % R_prior= calc_R_prior( inv_model, ... ) 0008 % 0009 % and will call the function inv_model.R_prior 0010 % parameters to R_prior should be passed in the field 0011 % inv_model.R_prior_function_name.parameters 0012 % 0013 % R_prior calculated regularization prior R 0014 % inv_model is an inv_model structure 0015 0016 % (C) 2005-2008 Andy Adler. License: GPL version 2 or version 3 0017 % $Id: calc_R_prior.html 2819 2011-09-07 16:43:11Z aadler $ 0018 0019 if isfield(inv_model,'rec_model'); 0020 inv_model.fwd_model= inv_model.rec_model; 0021 inv_model= rmfield(inv_model,'rec_model'); 0022 end 0023 0024 R_prior = eidors_obj('get-cache', inv_model, 'R_prior'); 0025 if ~isempty(R_prior) 0026 eidors_msg('calc_R_prior: using cached value', 3); 0027 return 0028 end 0029 0030 if isfield(inv_model,'R_prior') 0031 R_prior= feval( inv_model.R_prior, inv_model ); 0032 elseif isfield(inv_model,'RtR_prior') 0033 % The user has provided an RtR prior. We can use this to 0034 % get R =RtR^(1/2). Not that this is non unique 0035 RtR_prior= feval( inv_model.RtR_prior, inv_model ); 0036 0037 % chol generates an error for rank deficient RtR_prior 0038 % R_prior = chol (RtR_prior); 0039 % Instead we calculate cholinc with a droptol of 1e-5. 0040 % For priors, this should be fine, since exact values 0041 % especially far away, are not necessary 0042 ver = eidors_obj('interpreter_version'); 0043 opts.droptol = 1e-5; 0044 0045 if ver.isoctave || ver.ver < 7.012 0046 R_prior = cholinc(RtR_prior,opts.droptol); 0047 else 0048 R_prior = ichol(RtR_prior); 0049 end 0050 else 0051 error('calc_R_prior: neither R_prior or RtR_prior func provided'); 0052 end 0053 0054 if isfield(inv_model.fwd_model,'coarse2fine') 0055 c2f= inv_model.fwd_model.coarse2fine; 0056 if size(R_prior,1)==size(c2f,1) 0057 % we need to take into account coarse2fine - using a reasonable tol 0058 R_prior=R_prior*c2f; 0059 end 0060 end 0061 0062 eidors_obj('set-cache', inv_model, 'R_prior', R_prior); 0063 eidors_msg('calc_R_prior: setting cached value', 3);