dummy-link

OffsetArrays

Fortran-like arrays with arbitrary, zero or negative starting indices.

Readme

OffsetArrays.jl

Build Status codecov.io PkgEval

OffsetArrays provides Julia users with arrays that have arbitrary indices, similar to those found in some other programming languages like Fortran.

Usage

You can construct such arrays as follows:

OA = OffsetArray(A, axis1, axis2, ...)

where you want OA to have axes (axis1, axis2, ...) and be indexed by values that fall within these axis ranges. Example:

using OffsetArrays
A = reshape(1:15, 3, 5)
println("here is A:")
display(A)
OA = OffsetArray(A, -1:1, 0:4)    # OA will have axes (-1:1, 0:4)
println("here is OA:")
display(OA)
@show OA[-1,0] OA[1,4]

which prints out

here is A:
3×5 reshape(::UnitRange{Int64}, 3, 5) with eltype Int64:
 1  4  7  10  13
 2  5  8  11  14
 3  6  9  12  15
here is OA:
OffsetArray(reshape(::UnitRange{Int64}, 3, 5), -1:1, 0:4) with eltype Int64 with indices -1:1×0:4:
 1  4  7  10  13
 2  5  8  11  14
 3  6  9  12  15
OA[-1, 0] = 1
OA[1, 4] = 15

First Commit

01/31/2014

Last Touched

9 days ago

Commits

193 commits

Requires: