SciML / DiffEqGPU.jl

GPU-acceleration routines for DifferentialEquations.jl and the broader SciML scientific machine learning ecosystem
https://docs.sciml.ai/DiffEqGPU/stable/
MIT License
284 stars 29 forks source link

support non-array parameters #256

Closed pepijndevos closed 1 year ago

pepijndevos commented 1 year ago

In case the parameters are not an array of numbers, they get concatenated into a matrix, and then indexing returns an 1x1 matrix rather than the type of the parameters. I think this went unnoticed because it only worked for NullParameters and nobody actually looks at the NullParameters to see they are not an array.

What was happening, vs what's happening now:

julia> p
1×8 Matrix{LorenzParameters}:
 LorenzParameters(0.674407, 7.73146, 1.87812)  LorenzParameters(4.37845, 6.03229, 1.87617)  …  LorenzParameters(5.31718, 2.12004, 2.46161)  LorenzParameters(3.91543, 7.20726, 1.17673)

julia> Base.maybeview(p, :, 1)
1-element view(::Matrix{LorenzParameters}, :, 1) with eltype LorenzParameters:
 LorenzParameters(0.6744069f0, 7.7314587f0, 1.8781189f0)

julia> Base.maybeview(p, 1)
LorenzParameters(0.6744069f0, 7.7314587f0, 1.8781189f0)

fixes #248