Skip to content

Commit

Permalink
Adjustments to AbstractQ intro in LinearAlgebra (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch authored Nov 29, 2022
1 parent f1ee2f2 commit d0d0bae
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BandedMatrices"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "0.17.8"
version = "0.17.9"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
36 changes: 22 additions & 14 deletions src/banded/bandedqr.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AdjointQType = isdefined(LinearAlgebra, :AdjointQ) ? LinearAlgebra.AdjointQ : Adjoint

_qr(::AbstractBandedLayout, ax, A) = _banded_qr(ax, A)
_banded_qr(_, A) = qr!(BandedMatrix{float(eltype(A))}(A, (bandwidth(A,1),bandwidth(A,1)+bandwidth(A,2))))

Expand Down Expand Up @@ -63,9 +65,9 @@ function banded_qr_lmul!(A, B)
B
end

function banded_qr_lmul!(adjA::Adjoint, B)
function banded_qr_lmul!(adjA::AdjointQType, B)
require_one_based_indexing(B)
A = adjA.parent
A = parent(adjA)
mA, nA = size(A.factors)
mB, nB = size(B,1), size(B,2)
if mA != mB
Expand Down Expand Up @@ -119,8 +121,8 @@ function banded_qr_rmul!(A, Q)
end
A
end
function banded_qr_rmul!(A, adjQ::Adjoint)
Q = adjQ.parent
function banded_qr_rmul!(A, adjQ::AdjointQType)
Q = parent(adjQ)
mQ, nQ = size(Q.factors)
mA, nA = size(A,1), size(A,2)
if nA != mQ
Expand Down Expand Up @@ -148,21 +150,27 @@ function banded_qr_rmul!(A, adjQ::Adjoint)
end

banded_lmul!(A::QRPackedQ, B::AbstractVecOrMat) = banded_qr_lmul!(A, B)
banded_lmul!(adjA::Adjoint{<:Any,<:QRPackedQ}, B::AbstractVecOrMat) = banded_qr_lmul!(adjA, B)
banded_lmul!(adjA::AdjointQType{<:Any,<:QRPackedQ}, B::AbstractVecOrMat) = banded_qr_lmul!(adjA, B)
banded_rmul!(A::AbstractMatrix, Q::QRPackedQ) = banded_qr_rmul!(A, Q)
banded_rmul!(A::AbstractMatrix, adjQ::Adjoint{<:Any,<:QRPackedQ}) = banded_qr_rmul!(A, adjQ)
banded_rmul!(A::AbstractMatrix, adjQ::AdjointQType{<:Any,<:QRPackedQ}) = banded_qr_rmul!(A, adjQ)

lmul!(A::QRPackedQ{<:Any,<:AbstractBandedMatrix}, B::AbstractVecOrMat) = banded_lmul!(A,B)
lmul!(adjA::Adjoint{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}, B::AbstractVecOrMat) = banded_lmul!(adjA,B)
lmul!(A::QRPackedQ{<:Any,BandedSubBandedMatrix{T,C,R,I1,I2}}, B::AbstractVecOrMat) where {T,C,R,I1<:AbstractUnitRange,I2<:AbstractUnitRange} =
lmul!(A::QRPackedQ{<:Any,<:AbstractBandedMatrix}, B::AbstractVector) = banded_lmul!(A,B)
lmul!(A::QRPackedQ{<:Any,<:AbstractBandedMatrix}, B::AbstractMatrix) = banded_lmul!(A,B)
lmul!(adjA::AdjointQType{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}, B::AbstractVector) = banded_lmul!(adjA,B)
lmul!(adjA::AdjointQType{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}, B::AbstractMatrix) = banded_lmul!(adjA,B)
lmul!(A::QRPackedQ{<:Any,BandedSubBandedMatrix{T,C,R,I1,I2}}, B::AbstractVector) where {T,C,R,I1<:AbstractUnitRange,I2<:AbstractUnitRange} =
banded_lmul!(A,B)
lmul!(A::QRPackedQ{<:Any,BandedSubBandedMatrix{T,C,R,I1,I2}}, B::AbstractMatrix) where {T,C,R,I1<:AbstractUnitRange,I2<:AbstractUnitRange} =
banded_lmul!(A,B)
lmul!(adjA::Adjoint{T,<:QRPackedQ{T,<:BandedSubBandedMatrix{T,C,R,I1,I2,t}}}, B::AbstractVecOrMat) where {T,C,R,I1<:AbstractUnitRange,I2<:AbstractUnitRange,t} =
lmul!(adjA::AdjointQType{T,<:QRPackedQ{T,<:BandedSubBandedMatrix{T,C,R,I1,I2,t}}}, B::AbstractVector) where {T,C,R,I1<:AbstractUnitRange,I2<:AbstractUnitRange,t} =
banded_lmul!(adjA,B)
lmul!(adjA::AdjointQType{T,<:QRPackedQ{T,<:BandedSubBandedMatrix{T,C,R,I1,I2,t}}}, B::AbstractMatrix) where {T,C,R,I1<:AbstractUnitRange,I2<:AbstractUnitRange,t} =
banded_lmul!(adjA,B)
# rmul!(A::AbstractMatrix, adjQ::Adjoint{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}) = banded_rmul!(A, adjA)
# rmul!(A::StridedMatrix, adjQ::Adjoint{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}) = banded_rmul!(A, adjA)
# rmul!(A::AbstractMatrix, adjQ::AdjointQType{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}) = banded_rmul!(A, adjA)
# rmul!(A::StridedMatrix, adjQ::AdjointQType{<:Any,<:QRPackedQ{<:Any,<:AbstractBandedMatrix}}) = banded_rmul!(A, adjA)
rmul!(A::StridedVecOrMat{T}, Q::QRPackedQ{T,B}) where {T<:BlasFloat,B<:AbstractBandedMatrix{T}} = banded_rmul!(A, Q)
rmul!(A::StridedVecOrMat{T}, adjQ::Adjoint{<:Any,<:QRPackedQ{T,B}}) where {T<:BlasComplex,B<:AbstractBandedMatrix{T}} = banded_rmul!(A, adjQ)
rmul!(A::StridedVecOrMat{T}, adjQ::Adjoint{<:Any,<:QRPackedQ{T,B}}) where {T<:BlasReal,B<:AbstractBandedMatrix{T}} = banded_rmul!(A, adjQ)
rmul!(A::StridedVecOrMat{T}, adjQ::AdjointQType{<:Any,<:QRPackedQ{T,B}}) where {T<:BlasComplex,B<:AbstractBandedMatrix{T}} = banded_rmul!(A, adjQ)
rmul!(A::StridedVecOrMat{T}, adjQ::AdjointQType{<:Any,<:QRPackedQ{T,B}}) where {T<:BlasReal,B<:AbstractBandedMatrix{T}} = banded_rmul!(A, adjQ)


function _banded_widerect_ldiv!(A::QR{T}, B) where T
Expand Down
6 changes: 3 additions & 3 deletions test/test_bandedlu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ struct _foo <: Number end
end

@testset "zero matrix" begin
for A in (BandedMatrix{Float64}(undef, 0,0, 1,1),
BandedMatrix{Float64}(undef, 0,3, 1,1),
BandedMatrix{Float64}(undef, 0,0, -1,-2))
for A in (BandedMatrix{Float64}(undef, (0,0), (1,1)),
BandedMatrix{Float64}(undef, (0,3), (1,1)),
BandedMatrix{Float64}(undef, (0,0), (-1,-2)))
@test lu(A).factors == zeros(size(A)...)
@test lu(A) \ zeros(0) == zeros(0)
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_bandedqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Random.seed!(0)
@test qr(V) isa QR{Float64,<:BandedMatrix{Float64}}
@test qr(V).R qr(Matrix(V)).R
@test qr(V).τ LinearAlgebra.qrfactUnblocked!(Matrix(V)).τ
@test qr(V).Q qr(Matrix(V)).Q
@test Matrix(qr(V).Q) Matrix(qr(Matrix(V)).Q)
@test Matrix(qr(V)) V
B = BandedMatrix(A,(1,2)) # pad
V = view(copy(B),1:5,1:6)
Expand Down

2 comments on commit d0d0bae

@dkarrasch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/73118

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.17.9 -m "<description of version>" d0d0baec671636ef3a03c499a889986b25710625
git push origin v0.17.9

Please sign in to comment.