Skip to content

Commit f1f6857

Browse files
committed
Faster matrix sqrt for upper triangular matrices.
Replacing Val(::Bool) in an argument list with an explicit if makes the call type stable. The issue was discussed in JuliaLang#31007.
1 parent dfee945 commit f1f6857

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

stdlib/LinearAlgebra/src/triangular.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,13 @@ function sqrt(A::UpperTriangular)
23922392
end
23932393
end
23942394
end
2395-
sqrt(A,Val(realmatrix))
2395+
# Writing an explicit if instead of using Val(realmatrix) below
2396+
# makes the calls to sqrt(::UpperTriangular,::Val) type stable.
2397+
if realmatrix
2398+
return sqrt(A,Val(true))
2399+
else
2400+
return sqrt(A,Val(false))
2401+
end
23962402
end
23972403
function sqrt(A::UpperTriangular{T},::Val{realmatrix}) where {T,realmatrix}
23982404
B = A.data

0 commit comments

Comments
 (0)