Matrix free GMRES with structs?

I am wondering if there is a way to solve Ax=b with GMRES where x is not a regular vector but a struct consisting of different vectors? A is available as a linearmap/function but I am not how to use GMRES here since x is not one particular vector but a struct consisting of different vectors. Any help would be appreciated!

Maybe use https://github.com/jonniedie/ComponentArrays.jl ?

1 Like

try KrylovKit

4 Likes

@Srikumar
All solvers in Krylov.jl are matrix-free which means that you can use your linearmap/function with GMRES (Factorization-free operators · Krylov.jl).

You will just need to adapt a little bit your linearmap such that mul!(y::Vector, A, x::Vector) is defined.

x2 = ...
y2 = ...

function mul!(y::Vector, A, x::Vector)
  x2 .= x   # convert x in the type of your stuct consisting of different vectors
  mul!(y2, A, x2)   # apply your operator-vector routine specialized for your structure  
  y .= y2  # store the result in a basic Vector
end
2 Likes