From 7e312efd3d799dae4246ec480ca6fb089478d426 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 22 Dec 2024 11:47:59 -0100 Subject: [PATCH 1/2] Add specialized `ldiv!` handling This fixes https://github.com/SciML/ComponentArrays.jl/issues/287 by just making sure to fallback to standard BLAS routines. --- src/linear_algebra.jl | 4 ++++ 1 file changed, 4 insertions(+) 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 From 8e0fe7f851fcbbf4aebb6c3de0446383d78da1d9 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 22 Dec 2024 11:50:19 -0100 Subject: [PATCH 2/2] Update runtests.jl --- test/runtests.jl | 4 ++++ 1 file changed, 4 insertions(+) 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))