Performant arrays where each axis can be named
5 Stars
Updated Last
2 Years Ago
Started In
August 2014


Build Status

This package (not yet functional) for the Julia language will allow you to index arrays using names for the individual axes. This permits one to implement algorithms that are oblivious to the storage order of the underlying arrays. In contrast to similar approaches in Images.jl and NamedArrays.jl, this should enable implementation of all basic operations without introducing any runtime overhead.

A brief demo of some of the intended functionality:

A = rand(3, 5, 10)
B = NamedAxesArray(A, (:x, :y, :z))
Bslice = B[Ax{:y}(3)]  # equivalent to `slice(B, :, 3, :)`

# Compute the intensity-weighted mean along the z axis
Itotal = sumz = 0.0
for iter in eachelement(B)  # traverses in storage order for cache efficiency
    I = B[iter]  # intensity in a single voxel
    Itotal += I
    sumz += I * iter.z  # iter.z "looks up" the current z position
meanz = sumz/Itotal

The intention is that all of these operations are just as efficient as they would be if you used traditional position-based indexing with all the inherent assumptions about the storage order of B.