0001 function img= nodal_solve( inv_model, data1, data2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 dv = calc_difference_data( data1, data2, inv_model.fwd_model);
0019
0020 sol = eidors_cache(@get_RM, inv_model, 'nodal_solve' ) * dv;
0021
0022
0023 img.name= 'solved by nodal_solve';
0024 img.node_data = sol;
0025 img.fwd_model= inv_model.fwd_model;
0026
0027 function one_step_inv = get_RM( inv_model );
0028 fwd_model= inv_model.fwd_model;
0029
0030 img_bkgnd= calc_jacobian_bkgnd( inv_model );
0031 J = calc_jacobian(img_bkgnd);
0032
0033 RtR = calc_RtR_prior( inv_model );
0034 W = calc_meas_icov( inv_model );
0035 hp = calc_hyperparameter( inv_model );
0036
0037 [e2n,Ne, Nn] = elem2node( fwd_model.elems );
0038 if size(J,2) == Ne;
0039 J= J*e2n;
0040 end
0041 if size(RtR,2) == Ne;
0042 RtR = e2n'*RtR*e2n;
0043 RtR = RtR + 1e-4*spdiags(diag(RtR),0,Nn,Nn);
0044 end
0045
0046 one_step_inv= (J'*W*J + hp^2*RtR)\J'*W;
0047
0048 function [e2n, Ne, Nn] = elem2node( elems )
0049 [Ne,d] = size(elems);
0050 elemo = (1:Ne)'*ones(1,d);
0051 e2n = sparse(elemo,elems,1/d);
0052 Nn = size(e2n,2);