Skip to content

Commit

Permalink
LinearAlgebra: use instead of == for the tr tests in symmetri…
Browse files Browse the repository at this point in the history
…c.jl

After investigating JuliaLang/julia#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 16, 2024
1 parent 0945b9d commit 5f8a6cf
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 5f8a6cf

Please sign in to comment.