Skip to content

Commit

Permalink
Use P as the temporary matrix variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Nov 9, 2024
1 parent 80521ec commit caaafa2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,14 @@ function exp!(A::StridedMatrix{T}) where T<:BlasFloat
end
end

U′ = P # alias for the temporary matrix
mul!(U′, A, U)
# U = A * U, but we overwrite P to avoid an allocation
mul!(P, A, U)
# P may be seen as an alias for U in the following code

# Padé approximant: (V-U)\(V+U)
VminU, VplusU = V, U # Reuse already allocated arrays
for ind in eachindex(V, U)
vi, ui = V[ind], U′[ind]
vi, ui = V[ind], P[ind]
VminU[ind] = vi - ui
VplusU[ind] = vi + ui
end
Expand Down

0 comments on commit caaafa2

Please sign in to comment.