January 2020
Intermediate to advanced
532 pages
13h 31m
English
The OffsetArrays.jl package allows us to define arrays with arbitrary indices rather than the standard linear or cartesian style indices. A fun example is to use a zero-based array, just like the ones you may find in other programming languages:

To understand how this works, we need to dig into the source code. Let's keep things concise and review just a portion of the code:
struct OffsetArray{T,N,AA<:AbstractArray} <: AbstractArray{T,N} parent::AA offsets::NTuple{N,Int}endBase.parent(A::OffsetArray) = A.parentBase.size(A::OffsetArray) = size(parent(A))Base.size(A::OffsetArray, d) = size(parent(A), d) ...Read now
Unlock full access