0001 function [Gu,Glam]=getder(p,u,lam,r)
0002
0003 global pj lamj;
0004 bc=p.bcf(p,u,lam); zerov=zeros(p.neq,1); del=1e-6;
0005 if(p.jsw==0)
0006 [c,fu,flam,b]=p.jac(p,u,lam);
0007 [Gu,Glam]=assempde(bc,p.points,p.edges,p.tria,c,-fu,-flam);
0008 if(any(b)) Kadv=assemadv(p.points,p.tria,b);
0009
0010 Gu=Gu-Kadv;
0011 end
0012 end
0013 if(p.jsw==1)
0014 [c,fu,flam,b]=p.jac(p,u,lam);
0015 [Gu,Glam]=assempde(bc,p.points,p.edges,p.tria,c,-fu,zerov);
0016 if(any(b)) Kadv=assemadv(p.points,p.tria,b);
0017
0018 Gu=Gu-Kadv;
0019 end
0020 r1=resi(p,u,lam+del);Glam=-(r-r1)/del;
0021 end
0022 if(p.jsw==2)
0023 [S,F]=assempde(bc,p.points,p.edges,p.tria,0,ones(p.neq*p.neq,1),0,ones(p.np*p.neq,1));
0024 thresh=del*ones(size(u)); pj=p; lamj=lam;
0025 [Gu,fac,G]=numjac('resinj',0,u,r,thresh,[],0,S,[]);
0026 [c,fu,flam]=p.jac(p,u,lam);[Gus,Glam]=assempde(bc,p.points,p.edges,p.tria,c,-fu,-flam);
0027 end
0028 if(p.jsw==3)
0029 [S,F]=assempde(bc,p.points,p.edges,p.tria,0,ones(p.neq*p.neq,1),0,ones(p.np*p.neq,1));
0030 thresh=del*ones(size(u)); pj=p; lamj=lam;
0031 [Gu,fac,G]=numjac('resinj',0,u,r,thresh,[],0,S,[]);
0032 r1=resi(p,u,lam+del);Glam=-(r-r1)/del;
0033 end