-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathlazyarrays.jl
31 lines (28 loc) · 1.06 KB
/
lazyarrays.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@inline function _foldl_lazy_cat_vectors(rf, acc, vectors)
isempty(vectors) && return complete(rf, acc)
result = @return_if_reduced foldlargs(acc, vectors...) do acc, arr
foldl_nocomplete(rf, acc, arr)
end
return complete(rf, result)
end
"""
_foldl_lazy_hcat(rf, acc, coll::LazyArrays.Hcat)
"""
@inline _foldl_lazy_hcat(rf, acc, coll::AbstractMatrix) =
_foldl_lazy_cat_vectors(rf, acc, coll.arrays)
# Hcat currently always is an `AbstractMatrix`
"""
_foldl_lazy_vcat(rf, acc, coll::LazyArrays.Vcat)
"""
@inline function _foldl_lazy_vcat(rf, acc, coll)
isempty(coll.arrays) && return complete(rf, acc)
coll isa AbstractVector && return _foldl_lazy_cat_vectors(rf, acc, coll.arrays)
coll :: AbstractMatrix
for j in axes(coll, 2)
vectors = view.(coll.arrays, Ref(:), j)
acc = @return_if_reduced _foldl_lazy_cat_vectors(rf, acc, vectors)
end
return complete(rf, acc)
end
# Vcat currently always is an `AbstractVector` or `AbstractMatrix`
# TODO: write reduce for Vcat/Hcat which can be done in the "natural" order