Skip to content

Avoiding repeated allocations in mul! for CompositeMap #90

@JeffFessler

Description

@JeffFessler

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions