Skip to content

Commit 2f217a5

Browse files
Merge pull request #289 from SciML/ChrisRackauckas-patch-1
Add specialized `ldiv!` handling
2 parents 5f91b28 + 8e0fe7f commit 2f217a5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/linear_algebra.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ function LinearAlgebra.axpby!(α::Number, x::ComponentArray, β::Number, y::Comp
5757
axpby!(α, getdata(x), β, getdata(y))
5858
return ComponentArray(y, getaxes(y))
5959
end
60+
61+
function LinearAlgebra.ldiv!(B::AbstractVecOrMat, D::Diagonal{Float64, <:ComponentArray}, A::AbstractVecOrMat)
62+
ldiv!(B, Diagonal(Vector(D.diag)), A)
63+
end

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ end
536536
@test ldiv!(tempmat, lu(cmat + I), cmat) isa ComponentMatrix
537537
@test ldiv!(getdata(tempmat), lu(cmat + I), cmat) isa AbstractMatrix
538538

539+
c = (a=2, b=[1, 2]);
540+
x = ComponentArray(a=5, b=[(a=20., b=3.0), (a=33., b=2.0), (a=44., b=3.0)], c=c)
541+
@test ldiv!(rand(10),Diagonal(x), x) isa Vector
542+
539543
vca2 = vcat(ca2', ca2')
540544
hca2 = hcat(ca2, ca2)
541545
temp = ComponentVector(q = 100, r = rand(3, 3, 3))

0 commit comments

Comments
 (0)