Skip to content

Commit beb0c7d

Browse files
jishnubKristofferC
authored andcommitted
LAPACK: Aggressive constprop to concretely infer syev!/syevd! (#55295)
Currently, these are inferred as a 2-Tuple of possible return types depending on `jobz`, but since `jobz` is usually a constant, we may propagate it aggressively and have the return types inferred concretely. (cherry picked from commit 686804d)
1 parent 36ff239 commit beb0c7d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

stdlib/LinearAlgebra/src/lapack.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5183,7 +5183,7 @@ for (syev, syevr, syevd, sygvd, elty) in
51835183
# INTEGER INFO, LDA, LWORK, N
51845184
# * .. Array Arguments ..
51855185
# DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
5186-
function syev!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
5186+
Base.@constprop :aggressive function syev!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
51875187
chkstride1(A)
51885188
n = checksquare(A)
51895189
W = similar(A, $elty, n)
@@ -5277,7 +5277,7 @@ for (syev, syevr, syevd, sygvd, elty) in
52775277
# * .. Array Arguments ..
52785278
# INTEGER IWORK( * )
52795279
# DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
5280-
function syevd!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
5280+
Base.@constprop :aggressive function syevd!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
52815281
chkstride1(A)
52825282
n = checksquare(A)
52835283
chkuplofinite(A, uplo)
@@ -5368,7 +5368,7 @@ for (syev, syevr, syevd, sygvd, elty, relty) in
53685368
# * .. Array Arguments ..
53695369
# DOUBLE PRECISION RWORK( * ), W( * )
53705370
# COMPLEX*16 A( LDA, * ), WORK( * )
5371-
function syev!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
5371+
Base.@constprop :aggressive function syev!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
53725372
chkstride1(A)
53735373
chkuplofinite(A, uplo)
53745374
n = checksquare(A)
@@ -5476,7 +5476,7 @@ for (syev, syevr, syevd, sygvd, elty, relty) in
54765476
# INTEGER IWORK( * )
54775477
# DOUBLE PRECISION RWORK( * )
54785478
# COMPLEX*16 A( LDA, * ), WORK( * )
5479-
function syevd!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
5479+
Base.@constprop :aggressive function syevd!(jobz::AbstractChar, uplo::AbstractChar, A::AbstractMatrix{$elty})
54805480
chkstride1(A)
54815481
chkuplofinite(A, uplo)
54825482
n = checksquare(A)

stdlib/LinearAlgebra/test/lapack.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,4 +729,14 @@ a = zeros(2,0), zeros(0)
729729
@test_throws DimensionMismatch LinearAlgebra.LAPACK.getrs!('N', A, ipiv, b)
730730
end
731731

732+
@testset "inference in syev!/syevd!" begin
733+
for T in (Float32, Float64), CT in (T, Complex{T})
734+
A = rand(CT, 4,4)
735+
@inferred (A -> LAPACK.syev!('N', 'U', A))(A)
736+
@inferred (A -> LAPACK.syev!('V', 'U', A))(A)
737+
@inferred (A -> LAPACK.syevd!('N', 'U', A))(A)
738+
@inferred (A -> LAPACK.syevd!('V', 'U', A))(A)
739+
end
740+
end
741+
732742
end # module TestLAPACK

0 commit comments

Comments
 (0)