Skip to content

Commit

Permalink
Avoid undef error
Browse files Browse the repository at this point in the history
Signed-off-by: ErikQQY <[email protected]>
  • Loading branch information
ErikQQY committed Sep 11, 2024
1 parent 3047711 commit 8ff79f5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,21 @@ end
end

@inline function Base.similar(VA::VectorOfArray, dims::N) where {N}
VectorOfArray(similar(VA.u, dims))
l = length(VA)
if dims <= l
VectorOfArray([similar(VA[:, i]) for i in 1:l])
else
VectorOfArray([[similar(VA[:, i]) for i in 1:l]; [similar(VA.u[end]) for _ in (l+1):dims]])
end
end

@inline function Base.similar(VA::VectorOfArray, ::Type{T}, dims::N) where {N, T}
l = length(VA)
if dims <= l
VectorOfArray([similar(VA[:, i], T) for i in 1:l])
else
VectorOfArray([[similar(VA[:, i], T) for i in 1:l]; [similar(VA.u[end], T) for _ in (l+1):dims]])
end
end

@inline function Base.similar(VA::VectorOfArray{T, N, AT},
Expand Down

0 comments on commit 8ff79f5

Please sign in to comment.