IterativeSolvers.jl
IterativeSolvers.jl copied to clipboard
Simple diagonal preconditioners for linear maps
The following used to work
δx = cg(H, g; Pl=x -> ([πe;πte]) .\ x, tol=γ, maxiter=N)
where H is a LinearMap and Pl implements a diagonal preconditioner for it (I don't think the details are relevant, but let me know if you need more code), but now gives a
ERROR: LoadError: MethodError: no method matching ldiv!(::Array{Float64,1}, ::getfield(Main, Symbol("##3#6")){Array{Float64,1},Array{Float64,1}}, ::Array{Float64,1})
What is now the recommended way of implementing such a simple preconditioner? Do I need to define a full structure implementing all the different methods from the manual (which seems like overkill)?
See this https://github.com/JuliaMath/IterativeSolvers.jl/blob/01af27fe76069e6be566abfd862664f928997638/test/cg.jl#L12 for reference. There is only one function to be defined ldiv!(y, P, x).
Yes, that works, thank you!
Still, for this use case, the old behavior was much more convenient. Could I make the feature request to again provide a method that accepts an anonymous function for Pl -- or was there some compelling technical reason for dropping this?
Another convenience function might be to accept a LinearMap representing $P^{-1}$ -- i.e., whose mul! function implements ldiv! for $P$.
Check out Preconditioners.jl, which lets you do Pl = DiagonalPreconditioner([πe;πte]).