Skip to content

Commit 80c61f8

Browse files
ArunS-tackdkarrasch
authored andcommitted
Relax eltype condition in rdiv! with Diagonal (JuliaLang#40942)
Co-authored-by: Daniel Karrasch <[email protected]>
1 parent 4e1bfff commit 80c61f8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

stdlib/LinearAlgebra/src/diagonal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ function ldiv!(D::Diagonal, A::Union{LowerTriangular,UpperTriangular})
456456
A
457457
end
458458

459-
function rdiv!(A::AbstractMatrix{T}, D::Diagonal{T}) where {T}
459+
function rdiv!(A::AbstractMatrix, D::Diagonal)
460460
require_one_based_indexing(A)
461461
dd = D.diag
462462
m, n = size(A)

stdlib/LinearAlgebra/test/diagonal.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ Random.seed!(1)
403403

404404
end
405405

406+
@testset "rdiv! (#40887)" begin
407+
@test rdiv!(Matrix(Diagonal([2.0, 3.0])), Diagonal(2:3)) == Diagonal([1.0, 1.0])
408+
@test rdiv!(fill(3.0, 3, 3), 3.0I(3)) == ones(3,3)
409+
end
410+
406411
@testset "kron (issue #40595)" begin
407412
# custom array type to test that kron on Diagonal matrices preserves types of the parents if possible
408413
struct KronTestArray{T, N, AT} <: AbstractArray{T, N}

0 commit comments

Comments
 (0)