Skip to content

Commit 545fb0b

Browse files
committed
duplicate some type-dissimilar code in the inv function
detecting this code optimization (jump-threading) in the compiler is desirable, but generally very difficult
1 parent ef0c35f commit 545fb0b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

base/linalg/dense.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,15 @@ function inv(A::StridedMatrix{T}) where T
653653
AA = convert(AbstractArray{S}, A)
654654
if istriu(AA)
655655
Ai = inv(UpperTriangular(AA))
656+
Ai = convert(typeof(parent(Ai)), Ai)
656657
elseif istril(AA)
657658
Ai = inv(LowerTriangular(AA))
659+
Ai = convert(typeof(parent(Ai)), Ai)
658660
else
659661
Ai = inv(lufact(AA))
662+
Ai = convert(typeof(parent(Ai)), Ai)
660663
end
661-
return convert(typeof(parent(Ai)), Ai)
664+
return Ai
662665
end
663666

664667
"""

0 commit comments

Comments
 (0)