3 ms·
The first example is also the very first example in the docs[1], but rather f!(du,u,p,t) that modifies du, it passes f(u,p,t) that returns du. Searching the hel
by forgotpwd16 2y ago
The first example is also the very first example in the docs[1], but rather f!(du,u,p,t) that modifies du, it passes f(u,p,t) that returns du. Searching the help for ODEProblem() function, it's explained[2] that the first way is more memory-efficient, but if mutation is not allowed, the second way is more suitable. It will be of interest to write a follow-up post elaborating on this part.
[1]: https://docs.sciml.ai/DiffEqDocs/stable/examples/classical_physics/#Radioactive-Decay-of-Carbon-14 https://docs.sciml.ai/DiffEqDocs/stable/examples/classical_p...
[2]: https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#SciMLBase.ODEProblem https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#Sci...
- selimthegrim 2y agoI think I had volunteered to do something similar to this - let me check
- __rito__ 2y agoAuthor here. Yes, f(u,p,t) returning du is the suggested way to do things, but this pattern of updating du through in-place updating is more memory efficient when a system of equations (say 10-100) is involved. The suggested way, when we don't need to think about memory efficiency, is easier to write and reason about. I have plans to write more on this topic, and make it to a series. After I finish that, if there is enough interest, I will try and do a benchmark of mutating versus non-mutating styles with varying numbers of equations in a system of DEs. Thanks for reading the article and providing your opinion.