Skip to content

Commit

Permalink
LinearAlgebra: use instead of == for tr tests in symmetric.jl (
Browse files Browse the repository at this point in the history
…#55143)

After investigating #54090, I found that the issue was
not caused by the effects of `checksquare`, but by the use of the
`@simd` macro within `tr(::Matrix)`:

https://github.com/JuliaLang/julia/blob/0945b9d7740855c82a09fed42fbf6bc561e02c77/stdlib/LinearAlgebra/src/dense.jl#L373-L380

While simply removing the `@simd` macro was considered, the strict
left-to-right summation without `@simd` otherwise is not necessarily
more accurate, so I concluded that the problem lies in the test code,
which tests the (strict) equality of two different `tr` execution
results. I have modified the test code to use `≈` instead of `==`.

- fixes #54090
  • Loading branch information
aviatesk committed Jul 17, 2024
1 parent 2314ea6 commit c84b516
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/test/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ end

@testset "linalg unary ops" begin
@testset "tr" begin
@test tr(asym) == tr(Symmetric(asym))
@test tr(aherm) == tr(Hermitian(aherm))
@test tr(asym) tr(Symmetric(asym))
@test tr(aherm) tr(Hermitian(aherm))
end

@testset "isposdef[!]" begin
Expand Down

0 comments on commit c84b516

Please sign in to comment.