Skip to content

Commit a31a880

Browse files
authored
Reland " Avoid materializing arrays in bidiag matmul #55450" (#55777)
This relands #55450 and adds tests for the failing case noted in https://github.com/JuliaLang/julia/issues/55727. The `addmul` tests that were failing earlier pass with this change. The issue in the earlier PR was that we were not exiting quickly for `iszero(alpha)` in `_bibimul!` for small matrices, and were computing the result as `C .= A * B * alpha + C * beta`. The problem with this is that if `A * B` contains `NaN`s, this propagates to `C` even if `alpha === 0.0`. This is fixed now, and the result is only computed if `!iszero(alpha)`.
1 parent b8093de commit a31a880

File tree

5 files changed

+453
-52
lines changed

5 files changed

+453
-52
lines changed

stdlib/LinearAlgebra/src/LinearAlgebra.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,9 @@ matprod_dest(A::Diagonal, B::Diagonal, TS) = _matprod_dest_diag(B, TS)
673673
_matprod_dest_diag(A, TS) = similar(A, TS)
674674
function _matprod_dest_diag(A::SymTridiagonal, TS)
675675
n = size(A, 1)
676-
Tridiagonal(similar(A, TS, n-1), similar(A, TS, n), similar(A, TS, n-1))
676+
ev = similar(A, TS, max(0, n-1))
677+
dv = similar(A, TS, n)
678+
Tridiagonal(ev, dv, similar(ev))
677679
end
678680

679681
# Special handling for adj/trans vec

0 commit comments

Comments
 (0)