customized LinearSystemSolver for acgc. To solve: Ax-lam<x>=b With <x>=[triangle area]*C*x write (A-lam*nu eta)x=b and solve by Sherman-Morrison
0001 function x=gclss(A,b,p,lam) 0002 % customized LinearSystemSolver for acgc. 0003 % To solve: Ax-lam<x>=b 0004 % With <x>=[triangle area]*C*x write (A-lam*nu eta)x=b 0005 % and solve by Sherman-Morrison 0006 global eta nu; y=A\b; z=A\nu; al0=lam*eta*z; al=lam*eta*y/(1-al0); 0007 x=y+al*z; return % comment out to check Sherman-Morrison formula 0008 c1=(A-lam*p.nu*p.eta)*x; c2=(A-lam*p.nu*p.eta)*y; 0009 err1=norm(c1-b); err2=norm(c2-b); 0010 fprintf('lss: |b|=%g, |x|=%g, |y|=%g, SM-err=%g, noSM-err=%g\n',... 0011 norm(b),norm(x),norm(y),err1,err2); %pause