File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 548548# # Linear Algebra
549549
550550function ArrayInterface. zeromatrix (A:: ArrayPartition )
551- x = reduce (vcat, vec .(A. x))
551+ # Use foldl with explicit init to preserve array type (important for GPU arrays)
552+ # Starting with vec of first element ensures the result type matches the input
553+ vecs = vec .(A. x)
554+ rest = Base. tail (vecs)
555+ x = isempty (rest) ? vecs[1 ] : foldl (vcat, rest; init = vecs[1 ])
552556 return x .* x' .* false
553557end
554558
Original file line number Diff line number Diff line change 174174# Overwrite ArrayInterface zeromatrix to work with NamedArrayPartitions & implicit solvers within OrdinaryDiffEq
175175function ArrayInterface. zeromatrix (A:: NamedArrayPartition )
176176 B = ArrayPartition (A)
177- x = reduce (vcat, vec .(B. x))
177+ # Use foldl with explicit init to preserve array type (important for GPU arrays)
178+ vecs = vec .(B. x)
179+ rest = Base. tail (vecs)
180+ x = isempty (rest) ? vecs[1 ] : foldl (vcat, rest; init = vecs[1 ])
178181 return x .* x' .* false
179182end
180183
You can’t perform that action at this time.
0 commit comments