Closed DavidWellnitz closed 4 months ago
Yes, KrylovKit currently assumes that applying the operator creates a result that is memorywise independent from the input. If at some point inplace operators would be supported, it would be with two-argument versions f!(y, x)
where the result is stored iny
. I might be mistaken, but in my typical applications, there would be very few linear operators where it would make sense to apply them inplace in the sense of overwriting the input.
There is probably a way around it. I had originally written an inplace function to use with DifferentialEquations
, but when I realized my problem is linear, I thought KrylovKit
should be more efficient (and it seems to be). I was wondering if there is a way to pre-allocate the output vector (in the way you suggested), in order to improve efficiency, but from your comment that seems to not be the case.
Can I close this? Supporting in place functions and reducing memory allocation is certainly on the TODO list so I don't think this needs to stay open as an extra reminder.
Yes, go ahead!
I am trying to use
exponentiate
to compute a matrix exponential of an inplace defined function. The simplest way to reproduce the problem which I found iswhich returns
[3.95..., 3.95...]
instead of[2.71..., 2.71...]
. In contrastworks fine. Is there a reason why method 1 should not work?