Skip to content

Commit

Permalink
Merge pull request #121 from ChrisRackauckas/patch-1
Browse files Browse the repository at this point in the history
Overload lu_instance to it generates LU{ComponentMatrix}
  • Loading branch information
jonniedie authored Mar 5, 2022
2 parents 2abf21c + 8a833d9 commit a40d163
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/array_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ Base.parent(x::ComponentArray) = getfield(x, :data)

Base.size(x::ComponentArray) = size(getdata(x))
ArrayInterface.size(A::ComponentArray) = ArrayInterface.size(parent(A))

## https://github.com/SciML/DifferentialEquations.jl/issues/849
function ArrayInterface.lu_instance(x::ComponentMatrix)
T = eltype(x)
noUnitT = typeof(zero(T))
luT = LinearAlgebra.lutype(noUnitT)
ipiv = Vector{LinearAlgebra.BlasInt}(undef, 0)
info = zero(LinearAlgebra.BlasInt)
return LU{luT}(similar(x), ipiv, info)
end

Base.elsize(x::Type{<:ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = Base.elsize(A)

Expand Down Expand Up @@ -246,4 +256,4 @@ end
# Base.$f(x::Adjoint{T,<:AbstractVector{T}}, y::ComponentVector{T,A,Axes}) where {T<:Real,A,Axes} = $f(getdata(x), getdata(y))
# Base.$f(x::Transpose{T,<:AbstractVector{T}}, y::ComponentVector{T,A,Axes}) where {T<:Real,A,Axes} = $f(getdata(x), getdata(y))
# end
# end
# end

0 comments on commit a40d163

Please sign in to comment.