Skip to content

Commit f2559ac

Browse files
authored
Backport: Improve inference in axpy for non-inferred operator (#523)
1 parent b082783 commit f2559ac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Operators/Operator.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,11 @@ const WrapperOperator = Union{SpaceOperator,MultiplicationWrapper,DerivativeWrap
830830
## BLAS and matrix routines
831831
# We assume that copy may be overriden
832832

833-
axpy!(a, X::Operator, Y::AbstractMatrix) = (Y .= a .* AbstractMatrix(X) .+ Y)
833+
function axpy!(a, X::Operator, Y::AbstractMatrix)
834+
Y .+= a .* AbstractMatrix(X)
835+
# the explicit return statement improves type inference
836+
return Y
837+
end
834838
copyto!(dest::AbstractMatrix, src::Operator) = copyto!(dest, AbstractMatrix(src))
835839

836840
# this is for operators that implement copy via axpy!

0 commit comments

Comments
 (0)