Skip to content

Commit f5d4918

Browse files
authored
[LAPACK] Add a method to provide ipiv for sytrf! and hetrf! (#51705)
It's similar to what we have with `getrf!` / `geqrf!` and the vectors `ipiv` / `tau`.
1 parent 3cfda5a commit f5d4918

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

src/lapack.jl

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,11 +4195,10 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in
41954195
# * .. Array Arguments ..
41964196
# INTEGER IPIV( * )
41974197
# DOUBLE PRECISION A( LDA, * ), WORK( * )
4198-
function sytrf!(uplo::AbstractChar, A::AbstractMatrix{$elty})
4198+
function sytrf!(uplo::AbstractChar, A::AbstractMatrix{$elty}, ipiv::AbstractVector{BlasInt})
41994199
chkstride1(A)
42004200
n = checksquare(A)
42014201
chkuplo(uplo)
4202-
ipiv = similar(A, BlasInt, n)
42034202
if n == 0
42044203
return A, ipiv, zero(BlasInt)
42054204
end
@@ -4220,6 +4219,12 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in
42204219
return A, ipiv, info[]
42214220
end
42224221

4222+
function sytrf!(uplo::AbstractChar, A::AbstractMatrix{$elty})
4223+
n = checksquare(A)
4224+
ipiv = similar(A, BlasInt, n)
4225+
sytrf!(uplo, A, ipiv)
4226+
end
4227+
42234228
# SUBROUTINE DSYTRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
42244229
# * .. Scalar Arguments ..
42254230
# CHARACTER UPLO
@@ -4538,11 +4543,10 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in
45384543
# * .. Array Arguments ..
45394544
# INTEGER IPIV( * )
45404545
# COMPLEX*16 A( LDA, * ), WORK( * )
4541-
function hetrf!(uplo::AbstractChar, A::AbstractMatrix{$elty})
4546+
function hetrf!(uplo::AbstractChar, A::AbstractMatrix{$elty}, ipiv::AbstractVector{BlasInt})
45424547
chkstride1(A)
45434548
n = checksquare(A)
45444549
chkuplo(uplo)
4545-
ipiv = similar(A, BlasInt, n)
45464550
work = Vector{$elty}(undef, 1)
45474551
lwork = BlasInt(-1)
45484552
info = Ref{BlasInt}()
@@ -4560,6 +4564,12 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in
45604564
A, ipiv, info[]
45614565
end
45624566

4567+
function hetrf!(uplo::AbstractChar, A::AbstractMatrix{$elty})
4568+
n = checksquare(A)
4569+
ipiv = similar(A, BlasInt, n)
4570+
hetrf!(uplo, A, ipiv)
4571+
end
4572+
45634573
# SUBROUTINE ZHETRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
45644574
# * .. Scalar Arguments ..
45654575
# CHARACTER UPLO
@@ -4806,11 +4816,10 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in
48064816
# * .. Array Arguments ..
48074817
# INTEGER IPIV( * )
48084818
# COMPLEX*16 A( LDA, * ), WORK( * )
4809-
function sytrf!(uplo::AbstractChar, A::AbstractMatrix{$elty})
4819+
function sytrf!(uplo::AbstractChar, A::AbstractMatrix{$elty}, ipiv::AbstractVector{BlasInt})
48104820
chkstride1(A)
48114821
n = checksquare(A)
48124822
chkuplo(uplo)
4813-
ipiv = similar(A, BlasInt, n)
48144823
if n == 0
48154824
return A, ipiv, zero(BlasInt)
48164825
end
@@ -4831,6 +4840,12 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in
48314840
A, ipiv, info[]
48324841
end
48334842

4843+
function sytrf!(uplo::AbstractChar, A::AbstractMatrix{$elty})
4844+
n = checksquare(A)
4845+
ipiv = similar(A, BlasInt, n)
4846+
sytrf!(uplo, A, ipiv)
4847+
end
4848+
48344849
# SUBROUTINE ZSYTRI2( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
48354850
# * .. Scalar Arguments ..
48364851
# CHARACTER UPLO
@@ -5116,6 +5131,20 @@ zero at position `info`.
51165131
"""
51175132
sytrf!(uplo::AbstractChar, A::AbstractMatrix)
51185133

5134+
"""
5135+
sytrf!(uplo, A, ipiv) -> (A, ipiv, info)
5136+
5137+
Computes the Bunch-Kaufman factorization of a symmetric matrix `A`. If
5138+
`uplo = U`, the upper half of `A` is stored. If `uplo = L`, the lower
5139+
half is stored.
5140+
5141+
Returns `A`, overwritten by the factorization, the pivot vector `ipiv`, and
5142+
the error code `info` which is a non-negative integer. If `info` is positive
5143+
the matrix is singular and the diagonal part of the factorization is exactly
5144+
zero at position `info`.
5145+
"""
5146+
sytrf!(uplo::AbstractChar, A::AbstractMatrix, ipiv::AbstractVector{BlasInt})
5147+
51195148
"""
51205149
sytri!(uplo, A, ipiv)
51215150
@@ -5161,6 +5190,20 @@ zero at position `info`.
51615190
"""
51625191
hetrf!(uplo::AbstractChar, A::AbstractMatrix)
51635192

5193+
"""
5194+
hetrf!(uplo, A, ipiv) -> (A, ipiv, info)
5195+
5196+
Computes the Bunch-Kaufman factorization of a Hermitian matrix `A`. If
5197+
`uplo = U`, the upper half of `A` is stored. If `uplo = L`, the lower
5198+
half is stored.
5199+
5200+
Returns `A`, overwritten by the factorization, the pivot vector `ipiv`, and
5201+
the error code `info` which is a non-negative integer. If `info` is positive
5202+
the matrix is singular and the diagonal part of the factorization is exactly
5203+
zero at position `info`.
5204+
"""
5205+
hetrf!(uplo::AbstractChar, A::AbstractMatrix, ipiv::AbstractVector{BlasInt})
5206+
51645207
"""
51655208
hetri!(uplo, A, ipiv)
51665209

0 commit comments

Comments
 (0)