File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ function ldiv!(D::Diagonal, B::StridedVecOrMat)
437437 if di == 0
438438 throw (SingularException (i))
439439 end
440- B[i,j] / = di
440+ B[i,j] = di \ B[i,j]
441441 end
442442 end
443443 return B
Original file line number Diff line number Diff line change 414414 @test sqrt (D) == Diagonal ([sqrt ([1 2 ; 3 4 ]), sqrt ([1 2 ; 3 4 ])])
415415end
416416
417+ @testset " linear solve for block diagonal matrices" begin
418+ D = Diagonal ([rand (2 ,2 ) for _ in 1 : 5 ])
419+ b = [rand (2 ,2 ) for _ in 1 : 5 ]
420+ B = [rand (2 ,2 ) for _ in 1 : 5 , _ in 1 : 5 ]
421+ @test ldiv! (D, copy (b)) ≈ Diagonal (inv .(D. diag)) * b
422+ @test ldiv! (D, copy (B)) ≈ Diagonal (inv .(D. diag)) * B
423+ @test rdiv! (copy (B), D) ≈ B * Diagonal (inv .(D. diag))
424+ end
425+
417426@testset " multiplication with Symmetric/Hermitian" begin
418427 for T in (Float64, ComplexF64)
419428 D = Diagonal (randn (T, n))
You can’t perform that action at this time.
0 commit comments