Last active
December 18, 2015 14:19
-
-
Save karlnapf/5795898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [d,V] = det_Krylov_preconditioned(A,P,precomputed, tol,maxiter) | |
n = length(A); | |
V = probe(precomputed.colouring); | |
d= 0.0; | |
parfor iii=1:size(V,2) | |
workerNo = get(getCurrentTask,'ID'); | |
fprintf('det_Krylov_preconditioned %d/%d\n', iii, size(V,2)); | |
[tmp,iter]=ratKrylov01_preconditioned(A,V(:,iii),P,precomputed.wsq,precomputed.dzdt,precomputed.const,tol,maxiter); | |
d = d + V(:,iii)'*tmp; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [b,iter] = ratKrylov01_preconditioned(A, z,P,wsq,dzdt,const,tol,maxiter) | |
N=length(dzdt); | |
dim=length(z); | |
b=zeros(dim,1); | |
b0=zeros(dim,1); | |
I=speye(size(A)); | |
iter=0; | |
for jjj=1:N | |
% CG is done on matrix M=A-wsq(jjj)*I, where A is the preconditioned term | |
% Construct function M*x where Ax=P^(-1)*A*P^(-T)*x | |
Ax_func=@(x) P\(A*((P')\x)) -wsq(jjj)*I*x; | |
[b0,~,~,miter]=bicgstab(Ax_func,z,tol,maxiter,[],[],b0); | |
b=b-dzdt(jjj)*b0; | |
iter=iter+miter; | |
end | |
% b=const*A*imag(b); | |
b=const*(P\(A*((P')\imag(b)))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment