You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On 4633607ce9b9f077f32f89f09a136e04389bbac2 with Linux (either x86_64 or aarch64) I get
julia> Base.runtests("LinearAlgebra/addmul"; seed=0xca081a1e9adc6829030ff209636c84f4)
[...]
The global RNG seed was 0xca081a1e9adc6829030ff209636c84f4.
Error in testset LinearAlgebra/addmul:
Test Failed at ~/repo/julia/usr/share/julia/stdlib/v1.12/LinearAlgebra/test/addmul.jl:192
Expression: ≈(collect(returned_mat), α * Ac * Bc + β * Cc, rtol = rtol)
Evaluated: BigFloat[-0.0001400037216701636132108987549395176373104782747840190352000128617941687774417292;;] ≈ BigFloat[-0.0001400633263149390038358987549395176373104782747840190352000128617941687774417292;;] (rtol=0.00034526697709225118160247802734375)
Reduced to
julia> using LinearAlgebra
julia> α, β =true, big"1.4598638281754612311402752311551012098789215087890625";
julia> C = [big"-2.432162727109652065274123009949748377821320641416554145536270759853570050001279";;];
julia> Cc =collect(C);
julia> Af = Float32[0.50721234;;];
julia> Ac =collect(Af);
julia> Bf =Bidiagonal([7], Int64[], :U);
julia> Bc = [7;;];
julia> returned_mat =mul!(C, Af, Bf, α, β)
1×1 Matrix{BigFloat}:
-0.0001400037216701636132108987549395176373104782747840190352000128617941687774417292
julia> α * Ac * Bc + β * Cc
1×1 Matrix{BigFloat}:
-0.0001400633263149390038358987549395176373104782747840190352000128617941687774417292
Somewhat distressfully, this doesn't reproduce on aarch64-darwin, in the sense that the above reproducer gives
julia> returned_mat =mul!(C, Af, Bf, α, β)
1×1 Matrix{BigFloat}:
-0.0001400633263149390038358987549395176373104782747840190352000128617941687774417292
julia> α * Ac * Bc + β * Cc
1×1 Matrix{BigFloat}:
-0.0001400633263149390038358987549395176373104782747840190352000128617941687774417292
The text was updated successfully, but these errors were encountered:
The structured arrays seem to be a red herring in this one, and the issue may be reproduced using only Matrixes. Reduced further:
julia> α * Ac * Bc + β * C
1×1 Matrix{BigFloat}:-0.0001400633263149390038358987549395176373104782747840190352000128617941687774417292
julia>mul!(copy(C), Ac, Bc, α, β)
1×1 Matrix{BigFloat}:-0.0001400037216701636132108987549395176373104782747840190352000128617941687774417292
In the out-of-place case, the first multiplication α * Ac * Bc is carried out in Float32 precision, whereas in the second case, all the numbers are promoted to BigFloat first before the multiplication is carried out. This seems to explain the differences in the numbers:
This avoids the issues as in
https://github.com/JuliaLang/julia/issues/55781 and
https://github.com/JuliaLang/julia/issues/55779 where we compare small
numbers using a relative tolerance. Also, in this PR, I have added an
extra test, so now we compare both `A * B * alpha + C * beta` and `A * B
* alpha - C * beta` with the corresponding in-place versions. The idea
is that if the terms `A * B * alpha` and ` C * beta` have similar
magnitudes, at least one of the two expressions will usually result in a
large enough number that may be compared using a relative tolerance.
I am unsure if the `atol` chosen here is optimal, as I have ballparked
it to use the maximum `eps` by looking at all the `eltype`s involved.
Fixes #55781
Fixes #55779
On 4633607ce9b9f077f32f89f09a136e04389bbac2 with Linux (either x86_64 or aarch64) I get
Reduced to
Somewhat distressfully, this doesn't reproduce on aarch64-darwin, in the sense that the above reproducer gives
The text was updated successfully, but these errors were encountered: