For some reason, my code is well-defined with mutation of arrays.
However, when I’m trying to deal with the case of an array whose length is 1,
it is quite uncomfortable (for example, I have to use x .* x or x[1] * x[1] instead of x * x).
So I wonder if there is a way of mutating scalar variable.
Thank you.
Actually, there is no problem with x .* x. I just thought that it’s not intuitive to me (as it is not of my coding pattern).
BTW, make it Matrix seems nice
Actually, the main reason I wanted to mutate a scalar variable is to make it compatible with in-place method of DifferentialEquations.jl, while not changing variable’s type (i.e., remaining it as scalar).
In my experience, changing type of variables make many troubles. For example, I may have to change previous codes. Or, I may have to restart Julia REPL.
One remedy that I just thought is to utilise ComponentArrays.jl and assign a scalar into a ComponentArray (I’m not sure it works for in-place method of DiffEq.jl when a component of ComponentArray is scalar).
I’ll give a try and share my experience.
I hope so but I’ve not found a good way to use out-of-place method for SimulationLogger.jl, which is a convenient logging tool for DiffEq.
Unfortunately, I have to detour this issue till making it compatible with out-of-place (oop) method
EDIT: hmm… maybe it’s the time to consider to make it compatible with oop method.