Skip to content

Commit

Permalink
Ensure bidiagonal setindex! does not read indices in error message (#…
Browse files Browse the repository at this point in the history
…55342)

This fixes the error message if the matrix is uninitialized. This is
because a `Bidiagonal` with `uplo == 'L'` may still be `istriu` if the
subdiaognal is zero. We only care about the band index in the error
message, and not the values.
  • Loading branch information
jishnub authored Aug 3, 2024
1 parent 3d99c24 commit f2f188d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ end
@inbounds A.ev[A.uplo == 'U' ? i : j] = x
elseif !iszero(x)
throw(ArgumentError(LazyString(lazy"cannot set entry ($i, $j) off the ",
istriu(A) ? "upper" : "lower", " bidiagonal band to a nonzero value ", x)))
A.uplo == 'U' ? "upper" : "lower", " bidiagonal band to a nonzero value ", x)))
end
return x
end
Expand Down
5 changes: 5 additions & 0 deletions stdlib/LinearAlgebra/test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -984,4 +984,9 @@ end
@test Tridiagonal{Float64}(B) === Tridiagonal(evf, dvf, zf)
end

@testset "off-band indexing error" begin
B = Bidiagonal(Vector{BigInt}(undef, 4), Vector{BigInt}(undef,3), :L)
@test_throws "cannot set entry" B[1,2] = 4
end

end # module TestBidiagonal

2 comments on commit f2f188d

@vtjnash
Copy link
Member

@vtjnash vtjnash commented on f2f188d Aug 4, 2024

Choose a reason for hiding this comment

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

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

Please sign in to comment.