Skip to content

Commit

Permalink
Update the bunchkaufman.jl/getproperties! function to align to the an…
Browse files Browse the repository at this point in the history
…ti-aliasing implementation in #51763 + include comments in symmetriceigen.jl
  • Loading branch information
aravindh-krishnamoorthy committed Dec 5, 2023
1 parent 09f813b commit ed3fd1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stdlib/LinearAlgebra/src/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Base.propertynames(B::BunchKaufman, private::Bool=false) =
(:p, :P, :L, :U, :D, (private ? fieldnames(typeof(B)) : ())...)

function getproperties!(B::BunchKaufman{T,<:StridedMatrix}) where {T<:BlasFloat}
# NOTE: Copy of BunchKaufman's getproperty(B, :D) and getproperty(B, :L/U) since 'getproperty' is not in place.
# NOTE: Unlike in the 'getproperty' function, in this function L/U and D are computed in place.
if B.rook
LUD, od = LAPACK.syconvf_rook!(B.uplo, 'C', B.LD, B.ipiv)
else
Expand All @@ -289,12 +289,12 @@ function getproperties!(B::BunchKaufman{T,<:StridedMatrix}) where {T<:BlasFloat}
M = UnitUpperTriangular(LUD)
du = od[2:end]
# Avoid aliasing dl and du.
dl = B.symmetric ? copy(du) : conj.(du)
dl = B.symmetric ? du : conj.(du)
else
M = UnitLowerTriangular(LUD)
dl = od[1:end-1]
# Avoid aliasing dl and du.
du = B.symmetric ? copy(dl) : conj.(dl)
du = B.symmetric ? dl : conj.(dl)
end
return (M, Tridiagonal(dl, diag(LUD), du), B.p)
end
Expand Down
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/symmetriceigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ end
function eigvals!(A::StridedMatrix{T}, F::LU{T,<:StridedMatrix}; sortby::Union{Function,Nothing}=nothing) where {T}
L = UnitLowerTriangular(F.L)
U = UpperTriangular(F.U)
# Compute generalized eigenvalues of equivalent matrix:
# A' = inv(L)*(P*A)*inv(U)
# See: https://github.com/JuliaLang/julia/pull/50471#issuecomment-1627836781
permuterows!(A, F.p)
ldiv!(L, A)
rdiv!(A, U)
Expand Down

0 comments on commit ed3fd1e

Please sign in to comment.