calc_jacobian

PURPOSE ^

CALC_JACOBIAN: calculate jacobian from an inv_model

SYNOPSIS ^

function J = calc_jacobian( fwd_model, img)

DESCRIPTION ^

 CALC_JACOBIAN: calculate jacobian from an inv_model
 
  J = calc_jacobian( fwd_model, img )
  J = calc_jacobian( img )
      calc Jacobian on fwd_model at conductivity given
      in image (fwd_model is for forward and reconstruction)

 For reconstructions on dual meshes, the interpolation matrix
    is defined as fwd_model.coarse2fine. This takes
    coarse2fine * x_coarse = x_fine

 If the underlying jacobian calculator doesn't understand dual
    meshes, then calc_jacobian will automatically postmultiply
    by fwd_model.coarse2fine.

 img       is an image structure, with 'elem_data' or
           'node_data' parameters

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function J = calc_jacobian( fwd_model, img)
0002 % CALC_JACOBIAN: calculate jacobian from an inv_model
0003 %
0004 %  J = calc_jacobian( fwd_model, img )
0005 %  J = calc_jacobian( img )
0006 %      calc Jacobian on fwd_model at conductivity given
0007 %      in image (fwd_model is for forward and reconstruction)
0008 %
0009 % For reconstructions on dual meshes, the interpolation matrix
0010 %    is defined as fwd_model.coarse2fine. This takes
0011 %    coarse2fine * x_coarse = x_fine
0012 %
0013 % If the underlying jacobian calculator doesn't understand dual
0014 %    meshes, then calc_jacobian will automatically postmultiply
0015 %    by fwd_model.coarse2fine.
0016 %
0017 % img       is an image structure, with 'elem_data' or
0018 %           'node_data' parameters
0019 
0020 % (C) 2005-08 Andy Adler. License: GPL version 2 or version 3
0021 % $Id: calc_jacobian.html 2819 2011-09-07 16:43:11Z aadler $
0022 
0023 if nargin==1
0024    img       = fwd_model;
0025    fwd_model = img.fwd_model;
0026 end
0027 
0028 cache_obj= jacobian_cache_params( fwd_model, img );
0029 
0030 J= eidors_obj('get-cache', cache_obj, 'jacobian');
0031 if ~isempty(J)
0032    eidors_msg('calc_jacobian: using cached value', 3);
0033    return
0034 end
0035 
0036 J= feval(fwd_model.jacobian, fwd_model, img);
0037 
0038 if isfield(fwd_model,'coarse2fine')
0039    c2f= fwd_model.coarse2fine;
0040    if size(J,2)==size(c2f,1)
0041 %     calc_jacobian did not take into account the coarse2fine
0042       J=J*c2f;
0043    end
0044 end
0045 
0046 eidors_obj('set-cache', cache_obj, 'jacobian', J);
0047 eidors_msg('calc_jacobian: setting cached value', 3);
0048 
0049 % Make the Jacobian only depend on
0050 function cache_obj= jacobian_cache_params( fwd_model, img );
0051    if isfield(img, 'elem_data')
0052       cache_obj = {fwd_model, img.elem_data};
0053    elseif isfield(img, 'node_data')
0054       cache_obj = {fwd_model, img.node_data};
0055    else
0056       error('calc_jacobian: execting elem_data or node_data in image');
0057    end
0058

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005