solver.m.txt

来自「这是马尔可夫-蒙特卡罗算法的MATLAB源程序.」· 文本 代码 · 共 26 行

TXT
26
字号
function G = Solver(DR,d,pperm,rperm)
% G = Solver1(DR,d)
% Form the Green's functions by solving matrix eqn 

% Colin Fox, 29 Nov 2005

cf = 1; % 0=left divide (Gaussian elimination), 1=Cholesky factorise once and use factor to solve

[nnps,nnodes,nres,nbn]=nodenums(d.N);

SR = RedNodalMat(DR,d.RefNode);       % form the reduced nodal matrix
nelecs = length(d.ElecNodes);         % number of electrodes
%G = zeros(nnodes-1,nelecs);           % Allocate space for matrix of Green's functions

if ~cf
    % Make the data (in the simplest way)
    for ce = 1:nelecs 
        currvec = sparse(d.ElecNodes(ce),1,1,nnodes-1,1); % sparse current vector
        G(:,ce) = SR\currvec;          % solve using MatLab's left-divide
    end
else
    R = chol(SR(pperm,pperm));                      % Cholesky factorise 
    currmat = sparse(rperm(d.ElecNodes),1:nelecs,1,nnodes-1,nelecs); % make permuted currents
    U = R\(R'\currmat);
    G = full(U(rperm,:));
end

⌨️ 快捷键说明

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