SciML / LinearSolve.jl

LinearSolve.jl: High-Performance Unified Interface for Linear Solvers in Julia. Easily switch between factorization and Krylov methods, add preconditioners, and all in one interface.
https://docs.sciml.ai/LinearSolve/stable/
Other
242 stars 52 forks source link

RecursiveArrayTools.jl Support #384

Open anicusan opened 11 months ago

anicusan commented 11 months ago

Is there any way to use LinearSolve.jl algorithms with RecursiveArrayTools.ArrayPartition? Concrete example:

using RecursiveArrayTools
using DifferentialEquations
f!(du, u, p, t) = du .= 1.01 .* u
u0 = ArrayPartition([0.25, 0.5], [0.5, 0.75])
tspan = (0.0, 1.0)
prob = ODEProblem(f, u0, tspan)
sol = solve(prob, KenCarp47(linsolve = KrylovJL_GMRES()))

Fails with:

ERROR: LoadError: MethodError: no method matching ArrayPartition{Float64, Tuple{Vector{Float64}, Vector{Float64}}}(::UndefInitializer, ::Int64)

Closest candidates are:
  (::Type{ArrayPartition{T, S}} where {T, S<:Tuple})(::Any)
   @ RecursiveArrayTools ~/.julia/packages/RecursiveArrayTools/X30HP/src/array_partition.jl:27

<Stacktrace truncated>

Which - at a first glance - does not seem too horrible to fix. But would this be performant?

ChrisRackauckas commented 11 months ago

I think this could be made fast. The * operation can be done lazily so there's really no impediment here other than generalizing whatever computation is getting stuck