Skip to content

Commit

Permalink
bidiag_forwardsub! with padded
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Nov 29, 2024
1 parent befe4a0 commit ff20e01
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LazyArrays"
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
version = "2.2.4"
version = "2.2.5"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
3 changes: 2 additions & 1 deletion src/LazyArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import ArrayLayouts: AbstractQLayout, Dot, Dotu, Ldiv, Lmul, MatMulMatAdd, MatMu
hermitianlayout, layout_getindex, layout_replace_in_print_matrix, ldivaxes, materialize,
materialize!, mulreduce, reshapedlayout, rowsupport, scalarone, scalarzero, sub_materialize,
sublayout, symmetriclayout, symtridiagonallayout, transposelayout, triangulardata,
triangularlayout, tridiagonallayout, zero!, transtype, OnesLayout
triangularlayout, tridiagonallayout, zero!, transtype, OnesLayout,
diagonaldata, subdiagonaldata, supdiagonaldata

import FillArrays: AbstractFill, getindex_value

Expand Down
34 changes: 34 additions & 0 deletions src/padded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,37 @@ PaddedArray(A::T, n::Vararg{Integer,N}) where {T<:Number,N} = ApplyArray{T,N}(se


BroadcastStyle(::Type{<:PaddedArray{<:Any,N}}) where N = LazyArrayStyle{N}()



function ArrayLayouts._bidiag_forwardsub!(M::Ldiv{<:Any,<:PaddedColumns})
A, b_in = M.A, M.B
dv = diagonaldata(A)
ev = subdiagonaldata(A)
b = paddeddata(b_in)
N = length(b)
b[1] = bj1 = dv[1]\b[1]
@inbounds for j = 2:N
bj = b[j]
bj -= ev[j - 1] * bj1
dvj = dv[j]
if iszero(dvj)
throw(SingularEbception(j))

Check warning on line 607 in src/padded.jl

View check run for this annotation

Codecov / codecov/patch

src/padded.jl#L607

Added line #L607 was not covered by tests
end
bj = dvj\bj
b[j] = bj1 = bj
end

@inbounds for j = N+1:length(b_in)
iszero(bj1) && break
bj = -ev[j - 1] * bj1
dvj = dv[j]
if iszero(dvj)
throw(SingularException(j))

Check warning on line 618 in src/padded.jl

View check run for this annotation

Codecov / codecov/patch

src/padded.jl#L614-L618

Added lines #L614 - L618 were not covered by tests
end
bj = dvj\bj
b_in[j] = bj1 = bj
end

Check warning on line 622 in src/padded.jl

View check run for this annotation

Codecov / codecov/patch

src/padded.jl#L620-L622

Added lines #L620 - L622 were not covered by tests

b_in
end
6 changes: 6 additions & 0 deletions test/paddedtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ paddeddata(a::PaddedPadded) = a
@test C'b Matrix(C)'b
@test b'C b'Matrix(C)
end

@testset "Bidiagonal" begin
B = Bidiagonal(1:5, 1:4, :L)
b = Vcat(randn(5), Zeros(0))
@test ArrayLayouts.ldiv!(B, deepcopy(b)) B\b
end
end

end # module

0 comments on commit ff20e01

Please sign in to comment.