b=rand(2*N2,1); rho=norm(b); [Q,T]=Lanczos((A3-eye(512))'*(A3-eye(512)),b,200); [N,k]=size(Q); e1=zeros(k-1,1); e1(1)=1; y=sqrtm(T)\e1*rho; x=(A3-eye(512))*Q(:,1:k-1)*y; [U_W,S_W,V_W]=svd(A3-eye(512)); V=U_W*V_W'; z=V*b; norm(z-x) D=eye(512)+V; eigD=eig(D); plot(eigD,'+') m=0.0001; D=(1+m)/2*eye(512)+(1-m)/2*V; b=zeros(512,1);b(1)=1; [x,rr] = CGNE(D,b,zeros(512,1),1e-12,200); semilogy(1:2:2*max(size(rr)),rr,'-;CGNE;') hold [x,rr] = SCG(D,b,zeros(512,1),1e-12,200); semilogy(rr,'-.;SCG;') [rr,x] = SUMR(b,V,(1+m)/2,(1-m)/2,1e-12,200); semilogy(rr,':;SUMR;') xlabel("# matrix-vector") ylabel("residual norm") replot gset terminal postscript gset out "gw_conv_hist.ps" replot gset terminal x11 hold