4
4
5
5
This package exports one function, ` stack ` , for turning a list of arrays
6
6
into one ` AbstractArray ` . Given several arrays with the same ` eltype ` ,
7
- or an array of such arrays, it returns a lazy ` Stacked{T,N} ` view of these.
7
+ or an array of such arrays, it returns a lazy ` Stacked{T,N} ` view of these:
8
8
9
9
``` julia
10
10
stack ([zeros (2 ,2 ), ones (2 ,2 )]) # isa Stacked{Float64, 3, <:Vector{<:Matrix}}
@@ -13,18 +13,22 @@ stack([1,2,3], 4:6) # isa Stacked{Int, 2, <:Tuple{<:Vector, <:UnitRa
13
13
14
14
Given a generator, it instead iterates through the elements and writes into a new array.
15
15
Given a function and then some arrays, it behaves like ` map(f, A, B) ` but immediately writes
16
- the into a new array.
17
- The same ` stack_iter ` method is also used for any list of arrays of heterogeneous element type.
16
+ into a new array:
18
17
19
18
``` julia
20
19
stack ([i,2 i] for i in 1 : 5 ) # isa Matrix{Int} # size(ans) == (2, 5)
21
20
stack (* , eachcol (ones (2 ,4 )), 1 : 4 ) # == Matrix(stack(map(*, eachcol(...), 1:4)))
22
- stack ([1 ,2 ], [3.0 , 4.0 ], [5im , 6im ]) # isa Matrix{Number} # size(ans) == (2, 3)
23
21
```
24
22
25
- Notice that like ` map(identity, Any[1, 1.0, 5im]) ` , this promotes using
23
+ The same ` stack_iter ` method is also used for any list of arrays of heterogeneous element type,
24
+ and for arrays of tuples. Notice that like ` map(identity, Any[1, 1.0, 5im]) ` , this promotes using
26
25
` promote_typejoin ` , to ` Number ` here, rather than to ` Complex{Float64} ` .
27
26
27
+ ``` julia
28
+ stack ([1 ,2 ], [3.0 , 4.0 ], [5im , 6im ]) # isa Matrix{Number} # size(ans) == (2, 3)
29
+ stack ([(1 ,2.0 ,3 // 1 ) for i= 1 : 4 , j= 1 : 5 ])# isa Array{Real, 3} # size(ans) == (3, 4, 5)
30
+ ```
31
+
28
32
The slices must all have the same ` size ` , but they (and the container)
29
33
can have any number of dimensions. ` stack ` always places the slice dimensions first.
30
34
There are no options.
0 commit comments