Skip to content

Commit 6675052

Browse files
committed
Improve RFP coverage and some unrelated changes to general eigenvalue problem
1 parent e29d784 commit 6675052

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/eigenGeneral.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ module EigenGeneral
7676
iend = n
7777
HH = H.data
7878
τ = Rotation(Givens{T}[])
79-
@inbounds begin
80-
while true
79+
80+
@inbounds while true
8181
# Determine if the matrix splits. Find lowest positioned subdiagonal "zero"
8282
for istart = iend - 1:-1:1
8383
# debug && @printf("istart: %6d, iend %6d\n", istart, iend)
@@ -120,8 +120,8 @@ module EigenGeneral
120120
debug && @printf("Single shift! subdiagonal is: %10.3e\n", HH[iend, iend - 1])
121121

122122
# Calculate the Wilkinson shift
123-
λ1 = 0.5*(t + sqrt(t*t - 4d))
124-
λ2 = 0.5*(t - sqrt(t*t - 4d))
123+
λ1 = (t + sqrt(t*t - 4d))/2
124+
λ2 = (t - sqrt(t*t - 4d))/2
125125
σ = abs(Hmm - λ1) < abs(Hmm - λ2) ? λ1 : λ2
126126

127127
# Run a bulge chase
@@ -135,10 +135,10 @@ module EigenGeneral
135135
end
136136
if iend <= 2 break end
137137
end
138-
end
138+
139139
return Schur{T,typeof(HH)}(HH, τ)
140140
end
141-
schurfact!(A::StridedMatrix; tol = eps(), debug = false) = schurfact!(hessfact!(A), tol = tol, debug = debug)
141+
schurfact!(A::StridedMatrix; tol = eps(float(real(eltype(A)))), debug = false) = schurfact!(hessfact!(A), tol = tol, debug = debug)
142142

143143
function singleShiftQR!(HH::StridedMatrix, τ::Rotation, shift::Number, istart::Integer, iend::Integer)
144144
m = size(HH, 1)

src/lapack.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module LAPACK2
22

33
using Base.LinAlg: BlasInt, chkstride1, LAPACKException
44
using Base.LinAlg.BLAS: @blasfunc
5-
using Base.LinAlg.LAPACK: chkuplo
5+
using Base.LinAlg.LAPACK: chkdiag, chkuplo
66

77
# LAPACK wrappers
88
import Base.BLAS.@blasfunc

src/rectfullpacked.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ function Base.size(A::TriangularRFP)
114114
return (n, n)
115115
end
116116

117+
Base.copy(A::TriangularRFP) = TriangularRFP(copy(A.data), A.transr, A.uplo)
118+
117119
function Base.full(A::TriangularRFP)
118120
C = LAPACK2.tfttr!(A.transr, A.uplo, A.data)
119121
if A.uplo == 'U'
@@ -123,6 +125,9 @@ function Base.full(A::TriangularRFP)
123125
end
124126
end
125127

128+
Base.LinAlg.inv!(A::TriangularRFP) = TriangularRFP(LAPACK2.tftri!(A.transr, A.uplo, 'N', A.data), A.transr, A.uplo)
129+
Base.LinAlg.inv(A::TriangularRFP) = Base.LinAlg.inv!(copy(A))
130+
126131
struct CholeskyRFP{T<:BlasFloat} <: Factorization{T}
127132
data::Vector{T}
128133
transr::Char
@@ -139,6 +144,6 @@ Base.copy(F::CholeskyRFP{T}) where T = CholeskyRFP{T}(copy(F.data), F.transr, F.
139144
\(A::CholeskyRFP, B::StridedVecOrMat) = LAPACK2.pftrs!(A.transr, A.uplo, A.data, copy(B))
140145
\(A::HermitianRFP, B::StridedVecOrMat) = cholfact(A)\B
141146

142-
inv!(A::CholeskyRFP) = HermitianRFP(LAPACK2.pftri!(A.transr, A.uplo, A.data), A.transr, A.uplo)
143-
Base.LinAlg.inv(A::CholeskyRFP) = inv!(copy(A))
144-
Base.LinAlg.inv(A::HermitianRFP) = inv!(cholfact(A))
147+
Base.LinAlg.inv!(A::CholeskyRFP) = HermitianRFP(LAPACK2.pftri!(A.transr, A.uplo, A.data), A.transr, A.uplo)
148+
Base.LinAlg.inv(A::CholeskyRFP) = Base.LinAlg.inv!(copy(A))
149+
Base.LinAlg.inv(A::HermitianRFP) = Base.LinAlg.inv!(cholfact(A))

test/rectfullpacked.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ import LinearAlgebra: Ac_mul_A_RFP, TriangularRFP
6666

6767
@test_broken A A_RFP
6868
@test A full(A_RFP)
69+
@test inv(A) full(inv(A_RFP))
6970
end
7071
end

0 commit comments

Comments
 (0)