Skip to content

Commit

Permalink
Add 5-arg mul!
Browse files Browse the repository at this point in the history
This PR simply adds a 5-arg `mul!` for `AbstractDiffEqLinearOperator`.

I'd like this functionality to be able to compose more things together and facilitate in place computations of sums of ODE-like functions and linear operators, i.e. something like `f(u) + L * u`:

```julia
f(du, u, p, t) # some in-place function writes du <- f(u)
mul!(du, L, u, 1, 1) # du <- L * u + f(u)
```

I'm not sure this is the right way to add this, please let me know if I need to think more about it! 😅 My current thinking is that I could use that, but maybe there's just no need for it?  🤷
  • Loading branch information
briochemc authored Mar 26, 2021
1 parent 4a95d3d commit 7a2b738
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/operators/common_defaults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ for op in (:*, :/, :\), T in (:AbstractArray, :Number)
end
LinearAlgebra.mul!(Y::AbstractArray, L::AbstractDiffEqLinearOperator, B::AbstractArray) =
mul!(Y, convert(AbstractMatrix,L), B)
LinearAlgebra.mul!(Y::AbstractArray, L::AbstractDiffEqLinearOperator, B::AbstractArray, α::Number, β::Number) =
mul!(Y, convert(AbstractMatrix,L), B, α, β)
LinearAlgebra.ldiv!(Y::AbstractVecOrMat, L::AbstractDiffEqLinearOperator, B::AbstractVecOrMat) =
ldiv!(Y, convert(AbstractMatrix,L), B)
for pred in (:isreal, :issymmetric, :ishermitian, :isposdef)
Expand Down

0 comments on commit 7a2b738

Please sign in to comment.