RtR = calc_RtR_prior( inv_model ) CALC_RtR_PRIOR: calculate image regularization prior R'*R (which is an estimate of the inverse of the covariance) Typically, the image prior is matrix n_elem x n_elem of the normalized a priori crosscorrelation FEM element values calc_RtR_prior can be called as RtR_prior= calc_RtR_prior( inv_model, ... ) and will call the function inv_model.RtR_prior parameters to RtR_prior should be passed in the field inv_model.RtR_prior_function_name.parameters if there exists a field inv_model.rec_model, then the prior is calculated on the rec_model rather than the fwd_model. This will not be done if inv_model.prior_use_fwd_not_rec= 1; RtR_prior the calculated RtR regularization prior inv_model is an inv_model structure If a function to calculate RtR_prior is not provided, RtR = R_prior' * R_prior;
0001 function RtR_prior = calc_RtR_prior( inv_model ) 0002 % RtR = calc_RtR_prior( inv_model ) 0003 % CALC_RtR_PRIOR: calculate image regularization prior 0004 % R'*R (which is an estimate of the inverse of the covariance) 0005 % 0006 % Typically, the image prior is matrix n_elem x n_elem of the 0007 % normalized a priori crosscorrelation FEM element values 0008 % 0009 % calc_RtR_prior can be called as 0010 % RtR_prior= calc_RtR_prior( inv_model, ... ) 0011 % 0012 % and will call the function inv_model.RtR_prior 0013 % parameters to RtR_prior should be passed in the field 0014 % inv_model.RtR_prior_function_name.parameters 0015 % 0016 % if there exists a field inv_model.rec_model, then 0017 % the prior is calculated on the rec_model rather than 0018 % the fwd_model. This will not be done if 0019 % inv_model.prior_use_fwd_not_rec= 1; 0020 % 0021 % RtR_prior the calculated RtR regularization prior 0022 % inv_model is an inv_model structure 0023 % 0024 % If a function to calculate RtR_prior is not provided, 0025 % RtR = R_prior' * R_prior; 0026 0027 % (C) 2005-2008 Andy Adler. License: GPL version 2 or version 3 0028 % $Id: calc_RtR_prior.html 2819 2011-09-07 16:43:11Z aadler $ 0029 0030 inv_model = rec_or_fwd_model( inv_model); 0031 0032 RtR_prior = eidors_obj('get-cache', inv_model, 'RtR_prior'); 0033 if ~isempty(RtR_prior) 0034 eidors_msg('calc_RtR_prior: using cached value', 3); 0035 return 0036 end 0037 0038 if isfield(inv_model,'RtR_prior') 0039 RtR_prior= feval( inv_model.RtR_prior, inv_model ); 0040 elseif isfield(inv_model,'R_prior') 0041 % The user has provided an R prior. We can use this to 0042 % calculate RtR= R'*R; 0043 R= feval( inv_model.R_prior, inv_model ); 0044 0045 RtR_prior = R'*R; 0046 else 0047 error('calc_RtR_prior: neither R_prior or RtR_prior func provided'); 0048 end 0049 0050 if isfield(inv_model.fwd_model,'coarse2fine') 0051 c2f= inv_model.fwd_model.coarse2fine; 0052 if size(RtR_prior,1)==size(c2f,1) 0053 % we need to take into account coarse2fine - using a reasonable tol 0054 eidors_msg('calc_RtR_prior: using coarse2fine to model RtR'); 0055 f2c= c2f'; %pinv(c2f,1e-6); 0056 RtR_prior=c2f'*RtR_prior*c2f; 0057 end 0058 end 0059 0060 eidors_obj('set-cache', inv_model, 'RtR_prior', RtR_prior); 0061 eidors_msg('calc_RtR_prior: setting cached value', 3); 0062 0063 function inv_model = rec_or_fwd_model( inv_model); 0064 0065 if isfield(inv_model,'rec_model'); 0066 use_rec_model = 1; 0067 try if inv_model.prior_use_fwd_not_rec== 1; 0068 use_rec_model = 0; 0069 end; end 0070 0071 if use_rec_model 0072 inv_model.fwd_model= inv_model.rec_model; 0073 inv_model= rmfield(inv_model,'rec_model'); 0074 end 0075 end