JuliennedArrays.jl

JuliennedArrays.jl

struct True

Typed true

source
struct False

Typed false

source
Slices(whole, along...)

Slice whole into views.

along, made of True and False objects, shows which dimensions will be replaced with : when slicing.

julia> using JuliennedArrays

julia> whole = [1 2; 3 4];

julia> sliced = Slices(whole, False(), True())
2-element Slices{SubArray{Int64,1,Array{Int64,2},Tuple{Int64,Base.OneTo{Int64}},true},1,Array{Int64,2},Tuple{False,True}}:
 [1, 2]
 [3, 4]

julia> sliced[1] == whole[1, :]
true

julia> sliced[1] = [2, 1];

julia> whole
2×2 Array{Int64,2}:
 2  1
 3  4

julia> larger = rand(5, 5, 5);

julia> larger_sliced = Slices(larger, True(), False(), False());

julia> size(first(larger_sliced))
(5,)
source
Align(sliced, along...)

Align an array of arrays, all with the same size.

along, made of True and False objects, shows which dimensions will be taken up by the inner arrays. Inverse of Slices.

julia> using JuliennedArrays

julia> sliced = [[1, 2], [3, 4]];

julia> aligned = Align(sliced, False(), True())
2×2 Align{Int64,2,Array{Array{Int64,1},1},Tuple{False,True}}:
 1  2
 3  4

julia> aligned[1, :] == sliced[1]
true

julia> aligned[1, 1] = 0;

julia> sliced
2-element Array{Array{Int64,1},1}:
 [0, 2]
 [3, 4]
source