martinjrobins / diffsol

ODE solver library in Rust
https://martinjrobins.github.io/diffsol/
MIT License
25 stars 3 forks source link

use VectorView and VectorViewMut instead of &Vector and &mut Vector #47

Open martinjrobins opened 6 months ago

martinjrobins commented 6 months ago

atm the main call function for NonLinearOp is:

pub trait NonLinearOp: Op {
    /// Compute the operator at a given state and time.
    fn call_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::V);
    ...

To make this more flexible, we should use VectorView and VectorViewMut instead, ie:

pub trait NonLinearOp: Op {
    /// Compute the operator at a given state and time.
    fn call_inplace(&self, x: Self::VView, t: Self::T, y: Self::VViewMut);
    ...

This allows algorithms to call these functions with views rather than references to owned vectors. One usecase for this is to concatentate solves with varying parameters into a larger statevector

martinjrobins commented 6 months ago

needs to be done to all the callable functions, but perhaps start with call_inplace and see if there is any unexpected problems

martinjrobins commented 5 months ago

I'm a bit unsure doing this is worth the increased complexity. Could just use diffsl for concatenating solves.....

martinjrobins commented 3 weeks ago

however, it would allow me to reduce the amount of allocated memory for the solvers. Bdf solver stores diff as well as y and dy, even tho these overlap somewhat, simply because we need a separate vector for the state, and the op calls