Skip to content

Commit

Permalink
Faster matrix sqrt for upper triangular matrices. (JuliaLang#31100)
Browse files Browse the repository at this point in the history
Replacing Val(::Bool) in an argument list with an explicit if makes the 
call type stable. The issue was discussed in JuliaLang#31007.
  • Loading branch information
mateuszbaran committed May 2, 2020
1 parent f36036c commit 68c8708
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion stdlib/LinearAlgebra/src/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,13 @@ function sqrt(A::UpperTriangular)
end
end
end
sqrt(A,Val(realmatrix))
# Writing an explicit if instead of using Val(realmatrix) below
# makes the calls to sqrt(::UpperTriangular,::Val) type stable.
if realmatrix
return sqrt(A,Val(true))
else
return sqrt(A,Val(false))
end
end
function sqrt(A::UpperTriangular{T},::Val{realmatrix}) where {T,realmatrix}
B = A.data
Expand Down

0 comments on commit 68c8708

Please sign in to comment.