-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Replacing y=A*x
with mul!(y, A, x)
gives the (perhaps naive) user (e.g., me) the sense that no memory allocations will need to be made, and often that is the case.
But if A
is a CompositeMap
, e.g., A = B * C
, then internally A*x = B*(C*x)
and the current implementation will allocate a temporary variable for the product C*x
every time we do A*x
or the mul!
version. This overhead adds up when iterating.
We know the size of C
at the time we make the CompositeMap
, so in principle the LM package could allocate a work space for it and store it as part of the struct, so that mul!
operations would need no new allocations. (We'd also need a work space for B'
for the adjoint.)
Perhaps this could be a user-selectable option when creating a LinearMap
.
Thoughts on this feature suggestion? I might try it myself unless anyone sees flaws in it...