Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for Julia 1.10.7 #56381

Merged
merged 30 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bb62a53
Subtype: bug fix for bounds with deeper covariant var (#50832)
N5N3 Aug 10, 2023
56f51da
Fix remove-addrspaces pass in the presence of globals with addrspaces…
gbaraldi Oct 20, 2023
6c9897c
irrationals: restrict assume effects annotations to known types (#55886)
nsajko Oct 10, 2024
4c69200
update `hash` doc string: `widen` not required any more (#55867)
nsajko Oct 10, 2024
40f67ef
fix infinite recursion in `promote_type` for `Irrational` (#55870)
nsajko Oct 18, 2024
53adba9
REPL: don't complete str and cmd macros when the input matches the in…
IanButterworth Oct 23, 2024
7442535
Fix trampoline warning on x86 as well (#56280)
gbaraldi Oct 23, 2024
85aecff
recommend explicit `using Foo: Foo, ...` in package code (was: "using…
KristofferC Oct 26, 2024
0cf1432
Add compat entry for `Base.donotdelete` (#55773)
LilithHafner Sep 14, 2024
d48243f
inference: fix inference error from constructing invalid `TypeVar` (#…
aviatesk Oct 21, 2024
aa58f67
typeintersect: more fastpath to skip intersect under circular env (#5…
N5N3 Oct 23, 2024
f34528d
InteractiveUtils.jl: fixes issue where subtypes resolves bindings and…
dgleich Oct 24, 2024
2454b24
move time_imports and trace_* macros to Base but remain owned by Inte…
IanButterworth Oct 22, 2024
fe891d1
REPL: fix brace detection when ' is used for transpose (#56252)
IanButterworth Oct 21, 2024
b2be809
Make loading work when stdlib deps are missing in the manifest (#56148)
IanButterworth Oct 15, 2024
d830b45
Fix `pkgdir` for extensions (#55720)
IanButterworth Sep 10, 2024
27a0143
bump Pkg to latest 1.10
Oct 30, 2024
a03c5cd
Fix handling of virtual exit node in `PostDomTree` (#53739)
topolarity Mar 19, 2024
bb86259
update inference reflection usage for 1.10
KristofferC Oct 30, 2024
396b557
[backports-release-1.10] allow extensions to trigger from packages in…
topolarity Oct 31, 2024
f8eca8f
typeintersect: fix bounds merging during inner `intersect_all`.
N5N3 Jul 26, 2024
5337687
[backport-1.10] Fix dispatch for rdiv! with LU (#56415)
dkarrasch Nov 3, 2024
c6be3e9
🤖 [backports-release-1.10] Bump the SparseArrays stdlib from 279b363 …
DilumAluthgeBot Nov 4, 2024
c60704b
Fix compilation warning on aarch64-linux (#56480)
giordano Nov 7, 2024
69fa7fa
Fix warning about comparison of integer expressions of different sign…
giordano Mar 11, 2024
34612a7
Profile: mention `kill -s SIGUSR1 julia_pid` for Linux (#56441)
Moelf Nov 5, 2024
ca40417
The `info` in LAPACK calls should be a Ref instead of a Ptr (#56511)
ViralBShah Nov 9, 2024
6cda11c
Fix `(l/r)mul!` with `Diagonal`/`Bidiagonal` (#55052)
jishnub Nov 11, 2024
02468a5
Reinstate `similar` for `AbstractQ` for backward compatibility (#52694)
jishnub Nov 11, 2024
db84d85
Fix `log_quasitriu` for internal scaling `s=0` (#56311)
jishnub Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix (l/r)mul! with Diagonal/Bidiagonal (#55052)
  • Loading branch information
jishnub authored and N5N3 committed Nov 11, 2024
commit 6cda11c7067aacb1bd7085c86329b2b993e4babc
26 changes: 26 additions & 0 deletions stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,32 @@ end
/(A::Bidiagonal, B::Number) = Bidiagonal(A.dv/B, A.ev/B, A.uplo)
\(B::Number, A::Bidiagonal) = Bidiagonal(B\A.dv, B\A.ev, A.uplo)

# B .= D * B
function lmul!(D::Diagonal, B::Bidiagonal)
_muldiag_size_check(D, B)
(; dv, ev) = B
isL = B.uplo == 'L'
dv[1] = D.diag[1] * dv[1]
for i in axes(ev,1)
ev[i] = D.diag[i + isL] * ev[i]
dv[i+1] = D.diag[i+1] * dv[i+1]
end
return B
end

# B .= B * D
function rmul!(B::Bidiagonal, D::Diagonal)
_muldiag_size_check(B, D)
(; dv, ev) = B
isU = B.uplo == 'U'
dv[1] *= D.diag[1]
for i in axes(ev,1)
ev[i] *= D.diag[i + isU]
dv[i+1] *= D.diag[i+1]
end
return B
end

function ==(A::Bidiagonal, B::Bidiagonal)
if A.uplo == B.uplo
return A.dv == B.dv && A.ev == B.ev
Expand Down
45 changes: 43 additions & 2 deletions stdlib/LinearAlgebra/src/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,49 @@ end
(*)(D::Diagonal, A::HermOrSym) =
mul!(similar(A, promote_op(*, eltype(A), eltype(D.diag)), size(A)), D, A)

rmul!(A::AbstractMatrix, D::Diagonal) = @inline mul!(A, A, D)
lmul!(D::Diagonal, B::AbstractVecOrMat) = @inline mul!(B, D, B)
function rmul!(A::AbstractMatrix, D::Diagonal)
_muldiag_size_check(A, D)
for I in CartesianIndices(A)
row, col = Tuple(I)
@inbounds A[row, col] *= D.diag[col]
end
return A
end
# T .= T * D
function rmul!(T::Tridiagonal, D::Diagonal)
_muldiag_size_check(T, D)
(; dl, d, du) = T
d[1] *= D.diag[1]
for i in axes(dl,1)
dl[i] *= D.diag[i]
du[i] *= D.diag[i+1]
d[i+1] *= D.diag[i+1]
end
return T
end

function lmul!(D::Diagonal, B::AbstractVecOrMat)
_muldiag_size_check(D, B)
for I in CartesianIndices(B)
row = I[1]
@inbounds B[I] = D.diag[row] * B[I]
end
return B
end

# in-place multiplication with a diagonal
# T .= D * T
function lmul!(D::Diagonal, T::Tridiagonal)
_muldiag_size_check(D, T)
(; dl, d, du) = T
d[1] = D.diag[1] * d[1]
for i in axes(dl,1)
dl[i] = D.diag[i+1] * dl[i]
du[i] = D.diag[i] * du[i]
d[i+1] = D.diag[i+1] * d[i+1]
end
return T
end

function (*)(A::AdjOrTransAbsMat, D::Diagonal)
Ac = copy_similar(A, promote_op(*, eltype(A), eltype(D.diag)))
Expand Down
9 changes: 9 additions & 0 deletions stdlib/LinearAlgebra/test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -827,4 +827,13 @@ end
@test_throws "cannot set entry" B[1,2] = 4
end

@testset "rmul!/lmul! with banded matrices" begin
dv, ev = rand(4), rand(3)
for A in (Bidiagonal(dv, ev, :U), Bidiagonal(dv, ev, :L))
D = Diagonal(dv)
@test rmul!(copy(A), D) ≈ A * D
@test lmul!(D, copy(A)) ≈ D * A
end
end

end # module TestBidiagonal
13 changes: 13 additions & 0 deletions stdlib/LinearAlgebra/test/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1180,4 +1180,17 @@ end
@test *(Diagonal(ones(n)), Diagonal(1:n), Diagonal(ones(n)), Diagonal(1:n)) isa Diagonal
end

@testset "rmul!/lmul! with banded matrices" begin
@testset "$(nameof(typeof(B)))" for B in (
Bidiagonal(rand(4), rand(3), :L),
Tridiagonal(rand(3), rand(4), rand(3))
)
BA = Array(B)
D = Diagonal(rand(size(B,1)))
DA = Array(D)
@test rmul!(copy(B), D) ≈ B * D ≈ BA * DA
@test lmul!(D, copy(B)) ≈ D * B ≈ DA * BA
end
end

end # module TestDiagonal
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/test/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -802,4 +802,12 @@ end
end
end

@testset "rmul!/lmul! with banded matrices" begin
dl, d, du = rand(3), rand(4), rand(3)
A = Tridiagonal(dl, d, du)
D = Diagonal(d)
@test rmul!(copy(A), D) ≈ A * D
@test lmul!(D, copy(A)) ≈ D * A
end

end # module TestTridiagonal