Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "1.6.1"
version = "1.7"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
3 changes: 2 additions & 1 deletion src/BandedMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import ArrayLayouts: AbstractTridiagonalLayout, BidiagonalLayout, BlasMatLdivVec
colsupport, conjlayout, copymutable_oftype_layout, diagonaldata, dualadjoint, hermitiandata,
hermitianlayout, materialize, materialize!, reflector!, reflectorApply!, rowsupport,
sub_materialize, subdiagonaldata, sublayout, supdiagonaldata, symmetricdata, symmetriclayout,
symmetricuplo, transposelayout, triangulardata, triangularlayout, zero!
symmetricuplo, transposelayout, triangulardata, triangularlayout, zero!,
QRPackedQLayout, AdjQRPackedQLayout

import FillArrays: AbstractFill, getindex_value, _broadcasted_zeros, unique_value, OneElement, RectDiagonal

Expand Down
14 changes: 14 additions & 0 deletions src/banded/BandedMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -992,3 +992,17 @@ function show(io::IO, B::BandedMatrix)
end
print(io, ")")
end


###
# resize
###

function resize(A::BandedMatrix, n::Integer, m::Integer)
l,u = bandwidths(A)
_BandedMatrix(reshape(resize!(vec(bandeddata(A)), (l+u+1)*m), l+u+1, m), n, l,u)
end
function resize(A::BandedSubBandedMatrix, n::Integer, m::Integer)
l,u = bandwidths(A)
_BandedMatrix(reshape(resize!(vec(copy(bandeddata(A))), (l+u+1)*m), l+u+1, m), n, l,u)
end
8 changes: 8 additions & 0 deletions src/banded/bandedqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,11 @@ for BTyp in (:AbstractBandedMatrix, :BandedSubBandedMatrix), Typ in (:StridedVe
end
end
end



materialize!(M::Lmul{<:QRPackedQLayout{<:AbstractBandedLayout}}) = banded_qr_lmul!(M.A,M.B)
materialize!(M::Lmul{<:AdjQRPackedQLayout{<:AbstractBandedLayout}}) = banded_qr_lmul!(M.A,M.B)

materialize!(M::Rmul{<:Any,<:QRPackedQLayout{<:AbstractBandedLayout}}) = banded_qr_rmul!(M.A,M.B)
materialize!(M::Rmul{<:Any,<:AdjQRPackedQLayout{<:AbstractBandedLayout}}) = banded_qr_rmul!(M.A,M.B)
15 changes: 14 additions & 1 deletion test/test_banded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module TestBanded

using ArrayLayouts
using BandedMatrices
import BandedMatrices: _BandedMatrix
using BandedMatrices: _BandedMatrix, resize
using FillArrays
using LinearAlgebra
using SparseArrays
Expand Down Expand Up @@ -545,6 +545,19 @@ include("mymatrix.jl")
@test BandedMatrices.colrange(A, 3) == 3:3
@test BandedMatrices.colrange(A, 4) == 4:4
end

@testset "resize" begin
B = brand(5,6,2,1)
B̃ = resize(B, 10,7)
@test size(B̃) == (10,7)
@test bandwidths(B̃) == (2,1)
@test B̃[1:5,1:6] == B

C = resize(view(B,1:4,1:5), 10, 7)
@test size(C) == (10,7)
@test bandwidths(C) == (2,1)
@test C[1:4,1:5] == B[1:4,1:5]
end
end

end # module
16 changes: 13 additions & 3 deletions test/test_bandedqr.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TestBandedQR

using BandedMatrices, LinearAlgebra, Test, Random
using BandedMatrices, ArrayLayouts, LinearAlgebra, Test, Random
import BandedMatrices: banded_qr!
Random.seed!(0)

Expand Down Expand Up @@ -123,13 +123,23 @@ Random.seed!(0)
@test lmul!(Q', view(BandedMatrix(B,(size(B,1),2)),:,4:10)) ≈ Q'*B[:,4:10]
end

@testset "lmul!" begin
for T in (Float64,ComplexF64,Float32,ComplexF32)
A = brand(T,10,10,3,2)
Q,R = qr(A)
B = randn(T, 10, 2)
@test ArrayLayouts.lmul!(Q', copy(B)) == lmul!(Q', copy(B)) ≈ Q'B
@test ArrayLayouts.lmul!(Q, copy(B)) == lmul!(Q, copy(B)) ≈ Q*B
end
end

@testset "rmul!" begin
for T in (Float64,ComplexF64,Float32,ComplexF32)
A = brand(T,10,10,3,2)
Q,R = qr(A)
B = randn(T, 2, 10)
@test rmul!(copy(B), Q') ≈ B*Q'
@test rmul!(copy(B), Q) ≈ B*Q
@test ArrayLayouts.rmul!(copy(B), Q') == rmul!(copy(B), Q') ≈ B*Q'
@test ArrayLayouts.rmul!(copy(B), Q) == rmul!(copy(B), Q) ≈ B*Q
end
end
end
Expand Down