@@ -11,26 +11,21 @@ but if given code instead it will do what it can.
1111Typically produces `reshape(reinterpret(SArray...`; copy this to get `Array{SArray}`,
1212or call `static_slice(A, sizes, false)` to omit the reshape.
1313"""
14- @inline function static_slice (A:: AbstractArray{T,N} , sizes:: Size{tup} , finalshape :: Bool = true ) where {T,N,tup}
14+ @inline function static_slice (A:: AbstractArray{T,N} , sizes:: Size{tup} ) where {T,N,tup}
1515 IN = length (tup)
1616 for d in 1 : IN
1717 size (A,d) == tup[d] || throw (DimensionMismatch (" cannot slice array of size $(size (A)) using Size$tup " ))
1818 first (axes (A,d)) == 1 || throw (ArgumentError (" cannot creat static slices with offset indices" ))
1919 end
2020 IT = SArray{Tuple{tup... }, T, IN, prod (tup)}
21- @assert finalshape
22- # if N-IN>1 && finalshape
23- finalaxes = axes (A)[1 + IN: end ]
24- reshape (reinterpret (IT, vec (A)), finalaxes)
25- # else
26- # reinterpret(IT, vec(A)) # always a vector
27- # end
21+ finalaxes = axes (A)[1 + IN: end ]
22+ reshape (reinterpret (IT, vec (A)), finalaxes)
2823end
2924
30- function static_slice (A:: AbstractArray , code:: Tuple , finalshape :: Bool = true )
25+ function static_slice (A:: AbstractArray , code:: Tuple )
3126 iscodesorted (code) || error (" expected to make slices of left-most dimensions" )
3227 tup = ntuple (d -> size (A,d), countcolons (code))
33- static_slice (A, Size (tup), finalshape )
28+ static_slice (A, Size (tup))
3429end
3530
3631"""
3934Glues the output of `static_slice` back into one array, again with `code = (:,:,...,*,*)`.
4035For `MArray` slices, which can't be reinterpreted, this reverts to `red_glue`.
4136"""
42- @inline function static_glue (A:: AbstractArray{IT} , finalshape= true ) where {IT<: SArray }
43- if finalshape
44- finalsize = (size (IT)... , size (A)... )
45- reshape (reinterpret (eltype (IT), A), finalsize)
46- else
47- reinterpret (eltype (eltype (A)), A)
48- end
37+ @inline function static_glue (A:: AbstractArray{IT} ) where {IT<: SArray }
38+ finalaxes = (axes (IT)... , axes (A)... )
39+ reshape (reinterpret (eltype (IT), A), finalaxes)
4940end
5041
51- function static_glue (A:: AbstractArray{IT} , finalshape = true ) where {IT<: MArray }
52- stack (A)
42+ function static_glue (A:: AbstractArray{IT} ) where {IT<: MArray }
43+ LazyStack . stack (A)
5344end
5445
5546# This is now used only by maybestaticsizes...
0 commit comments