Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sol.u should be Array{T, 2} #1057

Closed
bertini97 opened this issue Oct 11, 2024 · 2 comments
Closed

sol.u should be Array{T, 2} #1057

bertini97 opened this issue Oct 11, 2024 · 2 comments

Comments

@bertini97
Copy link

Is your feature request related to a problem? Please describe.

sol.u is a time series (vector in time), and there are multiple ways in scientific libraries to represent them. Currently, sol.u is Vector{Float64} for 1D problems, and Vector{Vector{T}} for multi-D problems. This frustrates me for two reasons:

  1. I need my library to process AbstractArrays in the form arr[:, time] without handling the "special" 1D case. sol.u and sol array interface should be the same for everything.
  2. Each step is individually allocated. This might (inner workings mitigate this?) unreasonably ramp up the allocation, and result in bad cache performance when accessing.

Describe the solution you’d like

sol.u is an Array{T, 2}, and sol has an Array{T,2} interface. This would solve my two problems entirely.

Additional context

I know this would require a massive refactor and much work. If there is interest, I can collaborate. If you close this request, please at least provide information as to why Vector{Vector{T}} was chosen.

@ChrisRackauckas
Copy link
Member

sol.u is a time series (vector in time), and there are multiple ways in scientific libraries to represent them. Currently, sol.u is Vector{Float64} for 1D problems, and Vector{Vector{T}} for multi-D problems. This frustrates me for two reasons:

No it is not. It's a Vector{eltype(u)} which is not necessarily a vector.

I need my library to process AbstractArrays in the form arr[:, time] without handling the "special" 1D case. sol.u and sol array interface should be the same for everything.

You can always just do VectorOfArray(sol.u) (or DiffEqArray, etc.), but why not just use sol if you want that interface?

Each step is individually allocated. This might (inner workings mitigate this?) unreasonably ramp up the allocation, and result in bad cache performance when accessing.

No, it's the opposite. With adaptivity, you'd have to guess the matrix size. If you guess wrong, you'd have to re-allocate the matrix and copy pieces over. Copying vectors is straightforward and can even be done async to mask it. It ends up being a lot faster to push to. There's many experiments in the repo on this.

It's also not possible. You're only thinking of Array state. Your solution does not work for ComponentArrays for example. So it's a very short sighed proposal. Also, how do you support changing the size of u? That's no longer a matrix even if u0 is a vector.

@bertini97
Copy link
Author

Ah, I see. Completely reasonable, sorry for the waste of time. I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants