⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forward_solver.m

📁 用来实现三维阻抗及光学断层成像重建的matlab程序
💻 M
字号:
function [V] = forward_solver(vtx,E,I,tol,pp,V);
%function [V] = forward_solver(vtx,E,I,tol,pp,V);
%
%This function solves the forward problem using the Cholesky or LU method or 
%conjugate gradients. 
%
%
%
%vtx = The vertices
%E   = The full rank system matrix 
%I   = The currents matrix (RHS) 
%pp  = the column permutation vector 
%V   = The approximated nodal potential distribution
%tol = The tolerance in the forward solution, e.g. 1e-5




% d: number of current patterns
[bla,d] = size(I);

if nargin < 6
V = zeros(size(E,1),d);
end

if isreal(E)==1

    if  pp ~= 1:size(I,1) %There is a colum permutation, Cholesky opted
        %Permute the rows and columns to make the factors sparser
        E = E(pp,pp);
        In = I(pp,:);
        rr(pp)=1:max(size(pp));
        U = cholinc(E,tol);
        q_c =  U' \ In;
        Vn = U \ q_c;
        %De-permute the result for Cholesky
        V = Vn(rr,:);
    else

        %Alternatively use pcg ********
        K = cholinc(E,tol*100);
        for i=1:d
            [V(:,i),flag,relres,iter,resvec] = pcg(E,I(:,i),1e-6*norm(I(:,i)),d^3,K',K,V(:,i));
        end

    end

end %is real

if isreal(E)==0
    
    E = E(pp,pp);
    In = I(pp,:);
    rr(pp)=1:max(size(pp));
    [L,U] = luinc(E,tol); %Level of approximation, can be adjusted.
    q_c = L \ In;
    Vn = U \ q_c;
    %De-permute the result for Cholesky
    V = Vn(rr,:);

end %is complex




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is part of the EIDORS suite.
% Copyright (c) N. Polydorides 2001
% Copying permitted under terms of GNU GPL
% See enclosed file gpl.html for details.
% EIDORS 3D version 1.0
% MATLAB version 5.3 R11
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -