ComputationalScienceLaboratory / ODE-Test-Problems

A MATLAB suite of initial value problems
https://computationalsciencelaboratory.github.io/ODE-Test-Problems/
MIT License
9 stars 2 forks source link

RHS Operator Overloading and Enhancements #32

Closed Steven-Roberts closed 2 years ago

Steven-Roberts commented 2 years ago

Here are some ideas I had to improve the usability of otp.RHS.

To make partitioning easier, it would be neat for operators like *, \, .*, +, etc to be overloaded. For example:

rhsLeft = diag([1, 1, 0, 0]) * problem.RHS;
rhsRight = [0; 0; 1; 1]  .* problem.RHS;
rhsZero = 0 * problem.RHS;
rhs = rhsLeft + rhsRight + rhsZero;

Second, there is some inconsistency with RHS.Jacobian and similar properties in that they can be a matrix or a function handle depending on whether it is constant. I suggest adding dependent properties JacobianMatrix and JacobianFunction that consistently provide a matrix or function handle, respectively. It might be a bit confusing for users though.

AndreyAPopov commented 2 years ago

My only worry is that this will have a lot of redundant computation

Steven-Roberts commented 2 years ago

Fair point. It's mostly for convenience. We can document that there is redundant computations and overhead from wrapping things in another layer of functions