Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,11 @@ end
## Linear Algebra

function ArrayInterface.zeromatrix(A::ArrayPartition)
x = reduce(vcat, vec.(A.x))
# Use foldl with explicit init to preserve array type (important for GPU arrays)
# Starting with vec of first element ensures the result type matches the input
vecs = vec.(A.x)
rest = Base.tail(vecs)
x = isempty(rest) ? vecs[1] : foldl(vcat, rest; init = vecs[1])
return x .* x' .* false
end

Expand Down
5 changes: 4 additions & 1 deletion src/named_array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ end
#Overwrite ArrayInterface zeromatrix to work with NamedArrayPartitions & implicit solvers within OrdinaryDiffEq
function ArrayInterface.zeromatrix(A::NamedArrayPartition)
B = ArrayPartition(A)
x = reduce(vcat, vec.(B.x))
# Use foldl with explicit init to preserve array type (important for GPU arrays)
vecs = vec.(B.x)
rest = Base.tail(vecs)
x = isempty(rest) ? vecs[1] : foldl(vcat, rest; init = vecs[1])
return x .* x' .* false
end

Expand Down
Loading