Open
Description
Are there any examples to use InverseMap as a preconditioner?
From this links:
I've done something like using the diagonal as a preconditioner:
A = LinearMap(10; issymmetric=true, ismutating=true) do C,B
C[1] = -2B[1] + B[2]
for i in 2:length(B)-1
C[i] = B[i-1] - 2B[i] + B[i+1]
end
C[end] = B[end-1] - 2B[end]
return C
end
Pre = (a) -> LinearMap(10; issymmetric=true, ismutating=true) do C,B
C[1] =0.0
for i in 2:length(B)-1
C[i] = a[i,i]*B[i]
end
C[end] = 0.0
return C
end
aa = Matrix(-2.0*I(10))
foo(x) = InverseMap(Pre(aa); solver=IterativeSolvers.bicgstabl! )*x
struct MyPreconditioner{F}
fun::F
end
P = MyPreconditioner(foo)
using LinearAlgebra
LinearAlgebra.ldiv!(y, P::MyPreconditioner, x) = y .= P.fun(x)
LinearAlgebra.ldiv!(P::MyPreconditioner, x) = x .= P.fun(x)
b = rand(10)
sol = bicgstabl(A,b,Pl=P, log=true, max_mv_products=400)
but this says that the solution obtaininf
or naN
Metadata
Metadata
Assignees
Labels
No labels