Skip to content

Commit 9075235

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 #31007.
1 parent 7a1f294 commit 9075235

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
@@ -2586,7 +2586,13 @@ function sqrt(A::UpperTriangular)
25862586
end
25872587
end
25882588
end
2589-
sqrt(A,Val(realmatrix))
2589+
# Writing an explicit if instead of using Val(realmatrix) below
2590+
# makes the calls to sqrt(::UpperTriangular,::Val) type stable.
2591+
if realmatrix
2592+
return sqrt(A,Val(true))
2593+
else
2594+
return sqrt(A,Val(false))
2595+
end
25902596
end
25912597
function sqrt(A::UpperTriangular{T},::Val{realmatrix}) where {T,realmatrix}
25922598
B = A.data

0 commit comments

Comments
 (0)