From 326ec7281c0f7999e1681db6708ed358d4467a2c Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 17 Jul 2024 02:30:39 +0900 Subject: [PATCH] LinearAlgebra: use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- stdlib/LinearAlgebra/test/symmetric.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/LinearAlgebra/test/symmetric.jl b/stdlib/LinearAlgebra/test/symmetric.jl index 414b4ad5dd7227..89e9ca0d6a51d6 100644 --- a/stdlib/LinearAlgebra/test/symmetric.jl +++ b/stdlib/LinearAlgebra/test/symmetric.jl @@ -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