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 1.11.1 #56025

Merged
merged 26 commits into from
Oct 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
099d07f
fix rawbigints OOB issues (#55917)
nsajko Sep 29, 2024
359b9cc
Fix logic in `?` docstring example (#55945)
IanButterworth Oct 1, 2024
4eae986
REPL: make UndefVarError aware of imported modules (#55932)
IanButterworth Oct 2, 2024
f8a5b98
[build] avoid libedit linkage and align libccalllazy* SONAMEs (#55968)
cho-m Oct 3, 2024
4f81618
fix comma logic in time_print (#55977)
IanButterworth Oct 3, 2024
6a00b17
`@time` actually fix time report commas & add tests (#55982)
IanButterworth Oct 4, 2024
76967d4
Profile: document heap snapshot viewing tools (#55743)
nsajko Oct 5, 2024
bc75cd1
[REPL] Fix #55850 by using `safe_realpath` instead of `abspath` in `p…
christiangnrd Oct 5, 2024
a1b972f
Avoid `stat`-ing stdlib path if it's unreadable (#55992)
giordano Oct 5, 2024
6b8ef31
Fix no-arg `ScopedValues.@with` within a scope (#56019)
IanButterworth Oct 7, 2024
d21a6e8
🤖 [backports-release-1.11] Bump the Pkg stdlib from 6ceafca8e to aba9…
DilumAluthgeBot Oct 7, 2024
794ec9d
Don't show keymap `@error` for hints (#56041)
IanButterworth Oct 8, 2024
a9fd6db
effects: fix `Base.@_noub_meta` (#56061)
topolarity Oct 9, 2024
1d08207
Sockets: Warn when local network access not granted. (#56023)
maleadt Oct 7, 2024
3c9cf36
allow extensions to trigger from packages in [deps] (#54009)
KristofferC Apr 10, 2024
cb5596b
prevent loading other extensions when precompiling an extension (#55589)
KristofferC Sep 30, 2024
8f282d3
Replace regex package module checks with actual code checks (#55824)
IanButterworth Sep 23, 2024
0628fa0
Add a docs section about loading/precomp/ttfx time tuning (#55569)
IanButterworth Sep 14, 2024
0de7b6c
Revert "do not intentionally suppress errors in precompile script fro…
KristofferC Oct 9, 2024
c092d36
backport 1.11: fix `_growbeg!` unncessary resizing (#56029) (#56090)
dpinol Oct 10, 2024
1fa66d8
Provide better error hint when `UndefVarError` results from name clas…
ericphanson Mar 3, 2024
4751c23
fix overlapping definitions of `Base.active_module` and `REPL.active_…
JeffBezanson Aug 16, 2024
4cf3975
Remove warning from c when binding is ambiguous (#56103)
IanButterworth Oct 11, 2024
788775d
improve `allunique`'s type stability (#56161)
aviatesk Oct 15, 2024
66b620f
[LinearAlgebra] Remove unreliable doctests (#56011)
giordano Oct 6, 2024
4e03986
Fix zero elements for block-matrix kron involving Diagonal (#55941)
jishnub Oct 15, 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
Fix zero elements for block-matrix kron involving Diagonal (#55941)
jishnub committed Oct 15, 2024
commit 4e03986f3f070aa1645ad79f675b96c9c3bfba1c
70 changes: 63 additions & 7 deletions stdlib/LinearAlgebra/src/diagonal.jl
Original file line number Diff line number Diff line change
@@ -634,16 +634,33 @@ for Tri in (:UpperTriangular, :LowerTriangular)
end

@inline function kron!(C::AbstractMatrix, A::Diagonal, B::Diagonal)
valA = A.diag; nA = length(valA)
valB = B.diag; nB = length(valB)
valA = A.diag; mA, nA = size(A)
valB = B.diag; mB, nB = size(B)
nC = checksquare(C)
@boundscheck nC == nA*nB ||
throw(DimensionMismatch(lazy"expect C to be a $(nA*nB)x$(nA*nB) matrix, got size $(nC)x$(nC)"))
isempty(A) || isempty(B) || fill!(C, zero(A[1,1] * B[1,1]))
zerofilled = false
if !(isempty(A) || isempty(B))
z = A[1,1] * B[1,1]
if haszero(typeof(z))
# in this case, the zero is unique
fill!(C, zero(z))
zerofilled = true
end
end
@inbounds for i = 1:nA, j = 1:nB
idx = (i-1)*nB+j
C[idx, idx] = valA[i] * valB[j]
end
if !zerofilled
for j in 1:nA, i in 1:mA
Δrow, Δcol = (i-1)*mB, (j-1)*nB
for k in 1:nB, l in 1:mB
i == j && k == l && continue
C[Δrow + l, Δcol + k] = A[i,j] * B[l,k]
end
end
end
return C
end

@@ -670,7 +687,15 @@ end
(mC, nC) = size(C)
@boundscheck (mC, nC) == (mA * mB, nA * nB) ||
throw(DimensionMismatch(lazy"expect C to be a $(mA * mB)x$(nA * nB) matrix, got size $(mC)x$(nC)"))
isempty(A) || isempty(B) || fill!(C, zero(A[1,1] * B[1,1]))
zerofilled = false
if !(isempty(A) || isempty(B))
z = A[1,1] * B[1,1]
if haszero(typeof(z))
# in this case, the zero is unique
fill!(C, zero(z))
zerofilled = true
end
end
m = 1
@inbounds for j = 1:nA
A_jj = A[j,j]
@@ -681,6 +706,18 @@ end
end
m += (nA - 1) * mB
end
if !zerofilled
# populate the zero elements
for i in 1:mA
i == j && continue
A_ij = A[i, j]
Δrow, Δcol = (i-1)*mB, (j-1)*nB
for k in 1:nB, l in 1:nA
B_lk = B[l, k]
C[Δrow + l, Δcol + k] = A_ij * B_lk
end
end
end
m += mB
end
return C
@@ -693,17 +730,36 @@ end
(mC, nC) = size(C)
@boundscheck (mC, nC) == (mA * mB, nA * nB) ||
throw(DimensionMismatch(lazy"expect C to be a $(mA * mB)x$(nA * nB) matrix, got size $(mC)x$(nC)"))
isempty(A) || isempty(B) || fill!(C, zero(A[1,1] * B[1,1]))
zerofilled = false
if !(isempty(A) || isempty(B))
z = A[1,1] * B[1,1]
if haszero(typeof(z))
# in this case, the zero is unique
fill!(C, zero(z))
zerofilled = true
end
end
m = 1
@inbounds for j = 1:nA
for l = 1:mB
Bll = B[l,l]
for k = 1:mA
C[m] = A[k,j] * Bll
for i = 1:mA
C[m] = A[i,j] * Bll
m += nB
end
m += 1
end
if !zerofilled
for i in 1:mA
A_ij = A[i, j]
Δrow, Δcol = (i-1)*mB, (j-1)*nB
for k in 1:nB, l in 1:mB
l == k && continue
B_lk = B[l, k]
C[Δrow + l, Δcol + k] = A_ij * B_lk
end
end
end
m -= nB
end
return C
10 changes: 10 additions & 0 deletions stdlib/LinearAlgebra/test/diagonal.jl
Original file line number Diff line number Diff line change
@@ -1323,4 +1323,14 @@ end
@test checkbounds(Bool, D, diagind(D, IndexCartesian()))
end

@testset "zeros in kron with block matrices" begin
D = Diagonal(1:2)
B = reshape([ones(2,2), ones(3,2), ones(2,3), ones(3,3)], 2, 2)
@test kron(D, B) == kron(Array(D), B)
@test kron(B, D) == kron(B, Array(D))
D2 = Diagonal([ones(2,2), ones(3,3)])
@test kron(D, D2) == Diagonal([diag(D2); 2diag(D2)])
@test kron(D2, D) == Diagonal([ones(2,2), fill(2.0,2,2), ones(3,3), fill(2.0,3,3)])
end

end # module TestDiagonal