Skip to content

Commit 9bf880c

Browse files
authored
fix ambiguity of qr in v1.7 (#80)
1 parent 11fc725 commit 9bf880c

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/factorizations.jl

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ abstract type AbstractQRLayout <: MemoryLayout end
33
"""
44
QRCompactWYLayout{SLAY,TLAY}()
55
6-
represents a Compact-WY QR factorization whose
6+
represents a Compact-WY QR factorization whose
77
factors are stored with layout SLAY and τ stored with layout TLAY
88
"""
99
struct QRCompactWYLayout{SLAY,TLAY} <: AbstractQRLayout end
1010
"""
1111
QRPackedLayout{SLAY,TLAY}()
1212
13-
represents a Packed QR factorization whose
13+
represents a Packed QR factorization whose
1414
factors are stored with layout SLAY and τ stored with layout TLAY
1515
"""
1616
struct QRPackedLayout{SLAY,TLAY} <: AbstractQRLayout end
@@ -19,16 +19,16 @@ struct QRPackedLayout{SLAY,TLAY} <: AbstractQRLayout end
1919
"""
2020
LULayout{SLAY}()
2121
22-
represents a Packed QR factorization whose
22+
represents a Packed QR factorization whose
2323
factors are stored with layout SLAY and τ stored with layout TLAY
2424
"""
2525
struct LULayout{SLAY} <: AbstractQRLayout end
2626

27-
MemoryLayout(::Type{<:LinearAlgebra.QRCompactWY{<:Any,MAT}}) where MAT =
27+
MemoryLayout(::Type{<:LinearAlgebra.QRCompactWY{<:Any,MAT}}) where MAT =
2828
QRCompactWYLayout{typeof(MemoryLayout(MAT)),DenseColumnMajor}()
29-
MemoryLayout(::Type{<:LinearAlgebra.QR{<:Any,MAT}}) where MAT =
29+
MemoryLayout(::Type{<:LinearAlgebra.QR{<:Any,MAT}}) where MAT =
3030
QRPackedLayout{typeof(MemoryLayout(MAT)),DenseColumnMajor}()
31-
MemoryLayout(::Type{<:LinearAlgebra.LU{<:Any,MAT}}) where MAT =
31+
MemoryLayout(::Type{<:LinearAlgebra.LU{<:Any,MAT}}) where MAT =
3232
LULayout{typeof(MemoryLayout(MAT))}()
3333

3434
function materialize!(L::Ldiv{<:QRCompactWYLayout,<:Any,<:Any,<:AbstractVector})
@@ -114,9 +114,9 @@ struct AdjQRPackedQLayout{SLAY,TLAY} <: AbstractQLayout end
114114
struct QRCompactWYQLayout{SLAY,TLAY} <: AbstractQLayout end
115115
struct AdjQRCompactWYQLayout{SLAY,TLAY} <: AbstractQLayout end
116116

117-
MemoryLayout(::Type{<:LinearAlgebra.QRPackedQ{<:Any,S}}) where {S,T} =
117+
MemoryLayout(::Type{<:LinearAlgebra.QRPackedQ{<:Any,S}}) where {S,T} =
118118
QRPackedQLayout{typeof(MemoryLayout(S)),DenseColumnMajor}()
119-
MemoryLayout(::Type{<:LinearAlgebra.QRCompactWYQ{<:Any,S}}) where {S,T} =
119+
MemoryLayout(::Type{<:LinearAlgebra.QRCompactWYQ{<:Any,S}}) where {S,T} =
120120
QRCompactWYQLayout{typeof(MemoryLayout(S)),DenseColumnMajor}()
121121

122122
adjointlayout(::Type, ::QRPackedQLayout{SLAY,TLAY}) where {SLAY,TLAY} = AdjQRPackedQLayout{SLAY,TLAY}()
@@ -129,7 +129,7 @@ mulreduce(M::Mul{<:Any,<:AbstractQLayout}) = Rmul(M)
129129

130130
function copyto!(dest::AbstractArray{T}, M::Lmul{<:AbstractQLayout}) where T
131131
A,B = M.A,M.B
132-
if size(dest,1) == size(B,1)
132+
if size(dest,1) == size(B,1)
133133
copyto!(dest, B)
134134
else
135135
copyto!(view(dest,1:size(B,1),:), B)
@@ -149,13 +149,13 @@ materialize!(M::Rmul{LAY}) where LAY<:AbstractQLayout = error("Overload material
149149

150150
materialize!(M::Ldiv{<:AbstractQLayout}) = materialize!(Lmul(M.A',M.B))
151151

152-
materialize!(M::Lmul{<:QRPackedQLayout{<:AbstractColumnMajor,<:AbstractColumnMajor},<:AbstractColumnMajor,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasFloat =
153-
LAPACK.ormqr!('L','N',M.A.factors,M.A.τ,M.B)
152+
materialize!(M::Lmul{<:QRPackedQLayout{<:AbstractColumnMajor,<:AbstractColumnMajor},<:AbstractColumnMajor,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasFloat =
153+
LAPACK.ormqr!('L','N',M.A.factors,M.A.τ,M.B)
154154

155-
materialize!(M::Lmul{<:QRCompactWYQLayout{<:AbstractColumnMajor,<:AbstractColumnMajor},<:AbstractColumnMajor,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasFloat =
155+
materialize!(M::Lmul{<:QRCompactWYQLayout{<:AbstractColumnMajor,<:AbstractColumnMajor},<:AbstractColumnMajor,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasFloat =
156156
LAPACK.gemqrt!('L','N',M.A.factors,M.A.T,M.B)
157157

158-
function materialize!(M::Lmul{<:QRCompactWYQLayout{<:AbstractColumnMajor,<:AbstractColumnMajor},<:AbstractRowMajor,<:AbstractMatrix{T},<:AbstractMatrix{T}}) where T<:BlasReal
158+
function materialize!(M::Lmul{<:QRCompactWYQLayout{<:AbstractColumnMajor,<:AbstractColumnMajor},<:AbstractRowMajor,<:AbstractMatrix{T},<:AbstractMatrix{T}}) where T<:BlasReal
159159
LAPACK.gemqrt!('R','T',M.A.factors,M.A.T,transpose(M.B))
160160
M.B
161161
end
@@ -196,11 +196,11 @@ end
196196
### QcB
197197
materialize!(M::Lmul{<:AdjQRPackedQLayout{<:AbstractStridedLayout,<:AbstractStridedLayout},<:AbstractStridedLayout,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasFloat =
198198
(A = M.A.parent; LAPACK.ormqr!('L','T',A.factors,A.τ,M.B))
199-
materialize!(M::Lmul{<:AdjQRPackedQLayout{<:AbstractStridedLayout,<:AbstractStridedLayout},<:AbstractStridedLayout,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasComplex =
199+
materialize!(M::Lmul{<:AdjQRPackedQLayout{<:AbstractStridedLayout,<:AbstractStridedLayout},<:AbstractStridedLayout,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasComplex =
200200
(A = M.A.parent; LAPACK.ormqr!('L','C',A.factors,A.τ,M.B))
201201
materialize!(M::Lmul{<:AdjQRCompactWYQLayout{<:AbstractStridedLayout,<:AbstractStridedLayout},<:AbstractStridedLayout,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasFloat =
202202
(A = M.A.parent; LAPACK.gemqrt!('L','T',A.factors,A.T,M.B))
203-
materialize!(M::Lmul{<:AdjQRCompactWYQLayout{<:AbstractStridedLayout,<:AbstractStridedLayout},<:AbstractStridedLayout,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasComplex =
203+
materialize!(M::Lmul{<:AdjQRCompactWYQLayout{<:AbstractStridedLayout,<:AbstractStridedLayout},<:AbstractStridedLayout,<:AbstractMatrix{T},<:AbstractVecOrMat{T}}) where T<:BlasComplex =
204204
(A = M.A.parent; LAPACK.gemqrt!('L','C',A.factors,A.T,M.B))
205205
function materialize!(M::Lmul{<:AdjQRPackedQLayout})
206206
adjA,B = M.A, M.B
@@ -422,4 +422,6 @@ function ldiv!(C::Cholesky{<:Any,<:AbstractMatrix}, B::LayoutArray)
422422
end
423423
end
424424

425-
425+
if VERSION v"1.7-"
426+
@deprecate qr(A::LayoutMatrix, ::Val{true}) qr(A, ColumnNorm())
427+
end

test/test_layoutarray.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
100100

101101
@test qr(A) isa LinearAlgebra.QRCompactWY
102102
@test inv(A) inv(A.A)
103+
if VERSION v"1.7-"
104+
@test qr(A, Val(true)) == qr(A, ColumnNorm())
105+
end
103106

104107
S = Symmetric(MyMatrix(reshape(inv.(1:25),5,5) + 10I))
105108
@test cholesky(S).U @inferred(cholesky!(deepcopy(S))).U

0 commit comments

Comments
 (0)