Skip to content

Backport: Improve inference in axpy for non-inferred operator #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Operators/Operator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,11 @@ const WrapperOperator = Union{SpaceOperator,MultiplicationWrapper,DerivativeWrap
## BLAS and matrix routines
# We assume that copy may be overriden

axpy!(a, X::Operator, Y::AbstractMatrix) = (Y .= a .* AbstractMatrix(X) .+ Y)
function axpy!(a, X::Operator, Y::AbstractMatrix)
Y .+= a .* AbstractMatrix(X)
# the explicit return statement improves type inference
return Y
end
copyto!(dest::AbstractMatrix, src::Operator) = copyto!(dest, AbstractMatrix(src))

# this is for operators that implement copy via axpy!
Expand Down