Skip to content

Commit

Permalink
Branch elimination in Bidiagonal indexing with BandIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Sep 23, 2024
1 parent ec7dcb6 commit e0732e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ end
end

@inline function getindex(A::Bidiagonal{T}, b::BandIndex) where T
@boundscheck checkbounds(A, _cartinds(b))
@boundscheck checkbounds(A, b)
if b.band == 0
return @inbounds A.dv[b.index]
elseif b.band == _offdiagind(A.uplo)
elseif b.band (-1,1) && b.band == _offdiagind(A.uplo)
# we explicitly compare the possible bands as b.band may be constant-propagated
return @inbounds A.ev[b.index]
else
return bidiagzero(A, Tuple(_cartinds(b))...)
Expand Down

0 comments on commit e0732e7

Please sign in to comment.