-
Notifications
You must be signed in to change notification settings - Fork 42
Description
This is basically a follow-up to #56;
If I have a custom type for which I have a defined a allocation-free 5-arg mul!
struct MyIntegralOperator{T} <: LinearMap{T}
...
end
mul!(y, A::MyIntegralOperator, x, α=true, β=false) = ...
which I want to form linear combinations of, how do I get allocation-free application? Right now, I think I need to duplicate the following functions, since it is not possible for types outside of LinearMaps.jl to belong to FreeMap
:
and
A possible approach could be to tag the LinearCombination
object with a trait, i.e. a type parameter (e.g. MulStyle
) that indicates which method to dispatch to. Then the user would only need to overload mulstyle(::MyIntegralOperator) = FiveArgs
. This pattern has been used to great effect in e.g. https://github.com/JuliaArrays/LazyArrays.jl/blob/db8b20746c26873d635df18bcaac06382def11bb/src/linalg/muladd.jl