include "test.idp" cout << functionDEFINITION << "EigenValue" << endl; real t; real kc2 = 1.; func g = y*(1.-y); // Mesh border a0(t=0., 1.){x=5.; y=1.+2.*t;} border a1(t=0., 1.){x=5.-2.*t; y=3.;} border a2(t=0., 1.){x=3.-2.*t; y=3.-2.*t;} border a3(t=0., 1.){x=1.-t; y=1.;} border a4(t=0., 1.){x=0.; y=1.-t;} border a5(t=0., 1.){x=t; y=0.;} border a6(t=0., 1.){x=1.+4.*t; y=t;} mesh Th = buildmesh(a0(20) + a1(20) + a2(20) + a3(20) + a4(20) + a5(20) + a6(20)); // Fespace fespace Vh(Th, P1); Vh u, v; // Solve solve sound(u, v) = int2d(Th)( u*v * kc2 - dx(u)*dx(v) - dy(u)*dy(v) ) - int1d(Th, a4)( g * v ) ; real sigma = 20; //value of the shift varf op(u1, u2) = int2d(Th)( dx(u1)*dx(u2) + dy(u1)*dy(u2) - sigma* u1*u2 ) ; varf b([u1], [u2]) = int2d(Th)( u1*u2 ) ; matrix OP = op(Vh, Vh, solver=Crout, factorize=1); matrix B = b(Vh, Vh, solver=CG, eps=1e-20); // Eigen values int nev=1; real[int] ev(nev); Vh[int] eV(nev); t = clock(); int k=EigenValue(OP, B, sym=true, sigma=sigma, value=ev, vector=eV, tol=1e-10, nev=nev, maxit=0, ncv=0); t = clock() - t; cout << timeELAPSED << t << endl; real rounded = round(ev[0]); test(rounded == 20); func real[int] FOP1(real[int] & u){ real[int] Au = OP^-1*u; return Au; } func real[int] FB(real[int] & u){ real[int] Au = B*u; return Au; } int n = OP.n; int kk3 = EigenValue(n, A1=FOP1, B=FB, mode=3, sigma=sigma, value=ev, nev=nev); rounded = round(ev[0]); test(rounded == 20);