calc_RtR_prior

PURPOSE ^

RtR = calc_RtR_prior( inv_model )

SYNOPSIS ^

function RtR_prior = calc_RtR_prior( inv_model )

DESCRIPTION ^

 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 inv_model.RtR_prior is a matrix, calc_RtR_prior will return that matrix,
 possibly correcting for coarse2fine

 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;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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 inv_model.RtR_prior is a matrix, calc_RtR_prior will return that matrix,
0017 % possibly correcting for coarse2fine
0018 %
0019 % if there exists a field inv_model.rec_model, then
0020 %   the prior is calculated on the rec_model rather than
0021 %   the fwd_model. This will not be done if
0022 % inv_model.prior_use_fwd_not_rec= 1;
0023 %
0024 % RtR_prior    the calculated RtR regularization prior
0025 % inv_model    is an inv_model structure
0026 %
0027 % If a function to calculate RtR_prior is not provided,
0028 % RtR = R_prior' * R_prior;
0029 
0030 % (C) 2005-2008 Andy Adler. License: GPL version 2 or version 3
0031 % $Id: calc_RtR_prior.m 4833 2015-03-29 21:32:08Z bgrychtol-ipa $
0032 
0033 inv_model = rec_or_fwd_model( inv_model);
0034 
0035 if isfield(inv_model,'RtR_prior')
0036    if isnumeric(inv_model.RtR_prior)
0037       RtR_prior = inv_model.RtR_prior;
0038    else
0039       try inv_model.RtR_prior = str2func(inv_model.RtR_prior); end
0040       RtR_prior= eidors_cache( inv_model.RtR_prior, inv_model );
0041    end
0042 elseif isfield(inv_model,'R_prior')
0043    RtR_prior = eidors_cache(@calc_from_R_prior, inv_model, 'calc_RtR_prior');
0044 else
0045    error('calc_RtR_prior: neither R_prior nor RtR_prior provided');
0046 end
0047 
0048 if isfield(inv_model.fwd_model,'coarse2fine')
0049    c2f= inv_model.fwd_model.coarse2fine;
0050    if size(RtR_prior,1)==size(c2f,1)
0051 %     we need to take into account coarse2fine - using a reasonable tol
0052       eidors_msg('calc_RtR_prior: using coarse2fine to model RtR');
0053       f2c= c2f'; %pinv(c2f,1e-6);
0054       RtR_prior=f2c*RtR_prior*c2f;
0055    end
0056 end
0057 
0058 function RtR_prior = calc_from_R_prior(inv_model)
0059 
0060    % The user has provided an R prior. We can use this to
0061    % calculate RtR= R'*R;
0062    if isnumeric(inv_model.R_prior)
0063       R = inv_model.R_prior;
0064    else
0065       try inv_model.R_prior = str2func(inv_model.R_prior); end
0066       R= eidors_cache( inv_model.R_prior, inv_model );
0067    end
0068 
0069    RtR_prior = R'*R;
0070    
0071    
0072 
0073 function inv_model = rec_or_fwd_model( inv_model);
0074 
0075    if isfield(inv_model,'rec_model');
0076       use_rec_model = 1;
0077       try if inv_model.prior_use_fwd_not_rec== 1;
0078          use_rec_model = 0;
0079       end; end
0080 
0081       if use_rec_model
0082           % copy the normalize flag from the fwd_model to prevent warnings
0083          inv_model.rec_model = mdl_normalize(inv_model.rec_model, ...
0084                                        mdl_normalize(inv_model.fwd_model));
0085          inv_model.fwd_model= inv_model.rec_model;
0086          inv_model= rmfield(inv_model,'rec_model');
0087       end
0088    end

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005