You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common use-case: We have a linear solver (eg gmres) for a nep, and want to carry out deflation. The original linear solver will not directly work for the deflated nep due to the way it is modified. However, it is possible to define your own linear solver for the deflated nep. Since this is a common use-case, I suggest we incorporate this into the package in some way.
Illustration (only works for one deflated pair):
using NonlinearEigenproblems
using LinearAlgebra
import NonlinearEigenproblems.create_linsolver
import NonlinearEigenproblems.lin_solve
mutable struct MyLinSolverCreator <:LinSolverCreator
orglinsolvercreator
dnep
endmutable struct MyLinSolver <:LinSolver
orglinsolver
dnep
λ
endfunctioncreate_linsolver(creator::MyLinSolverCreator,dnep,λ)
orglinsolver=create_linsolver(creator.orglinsolvercreator,
dnep.orgnep,λ);
returnMyLinSolver(orglinsolver,dnep,λ);
endfunctionlin_solve(solver::MyLinSolver, b::AbstractVecOrMat;tol=0)
n0=size(solver.dnep.orgnep,1);
b1=b[1:n0];
b2=b[(n0+1):end];
z1=lin_solve(solver.orglinsolver,b1);
z2=b2;
# Now use Schur complement, i.e., that # inv([I x1 ; x2' 0])=# (1/α)*[(α*I+x1*x2') -x1 ; -x2' 1]# where x1=x/(λ-s)# x2=x
s=solver.dnep.S0[1,1];
x=solver.dnep.V0[:,1];
x1=x/(solver.λ-s)
x2=x;
α=(-x2'*x1)[1];
α=(-x2'*x1)[1];
q1=(α*z1+x1*(x2'*z1)[1]-x1*z2[1])/α
q2=(-x2'*z1+z2[1])/α
return [q1;q2];
end
nep=nep_gallery("dep0");
(λ,v)=newton(nep,v=ones(size(nep,1)));
dnep=deflate_eigpair(nep,λ,v)
# The underlying linsolver:
orglinsolver=BackslashLinSolverCreator();
creator=MyLinSolverCreator(orglinsolver,dnep);
(λ2,v2)=augnewton(dnep,
v=ones(size(dnep,1)),
linsolvercreator=creator,
logger=1); # this converges to different eigval
Note that the MyLinSolver is a linear solver for the dnep:
We might want to do it from scratch to get a good design. However, I think part of what we want is available in the function jd_inner_effenberger_linear_solver!, located at the end of method_jd.jl (here). It can handle a few deflated eigenvalues.
A common use-case: We have a linear solver (eg gmres) for a nep, and want to carry out deflation. The original linear solver will not directly work for the deflated nep due to the way it is modified. However, it is possible to define your own linear solver for the deflated nep. Since this is a common use-case, I suggest we incorporate this into the package in some way.
Illustration (only works for one deflated pair):
Note that the
MyLinSolver
is a linear solver for thednep
:The text was updated successfully, but these errors were encountered: