diff --git a/src/linear_algebra.jl b/src/linear_algebra.jl index 6c2efedb..8ba2cc13 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra.jl @@ -57,3 +57,7 @@ function LinearAlgebra.axpby!(α::Number, x::ComponentArray, β::Number, y::Comp axpby!(α, getdata(x), β, getdata(y)) return ComponentArray(y, getaxes(y)) end + +function LinearAlgebra.ldiv!(B::AbstractVecOrMat, D::Diagonal{Float64, <:ComponentArray}, A::AbstractVecOrMat) + ldiv!(B, Diagonal(Vector(D.diag)), A) +end diff --git a/test/runtests.jl b/test/runtests.jl index 01fa3575..b4c6fc0e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -536,6 +536,10 @@ end @test ldiv!(tempmat, lu(cmat + I), cmat) isa ComponentMatrix @test ldiv!(getdata(tempmat), lu(cmat + I), cmat) isa AbstractMatrix + c = (a=2, b=[1, 2]); + x = ComponentArray(a=5, b=[(a=20., b=3.0), (a=33., b=2.0), (a=44., b=3.0)], c=c) + @test ldiv!(rand(10),Diagonal(x), x) isa Vector + vca2 = vcat(ca2', ca2') hca2 = hcat(ca2, ca2) temp = ComponentVector(q = 100, r = rand(3, 3, 3))