MultiIndexArrays Library Functions

MultiIndexArrays.GridTensor — Type
GridTensor(tensor::MultiIndexLazyArray, w::Integer)

A rank-N lazy array over a single grid, with a stencil of width w. It holds a MultiIndexLazyArray — the coefficient function and the grid that size and getindex use — and w, the width of the stencil that stencil_indices returns for it.

The axes of tensor must all be the same grid, because a grid tensor has one grid, and w must be non-negative; each raises an ArgumentError. GridTensor keeps Base's OneTo axes, so its indices are the linear indices of that grid, in each of the index forms that MultiIndexLazyArray takes. Array(gt) materialises it, parent(gt) is the array it holds, and gt[n] is the nth entry of Array(gt).

julia> gt = GridTensor(MultiIndexLazyArray(Float64, (I, J, K) -> 1.0, (2, 3), (2, 3), (2, 3)), 1);

julia> size(gt)
(6, 6, 6)

julia> gt[1, 2, 3]
1.0
source
MultiIndexArrays.linearindex — Method
linearindex(I::CartesianIndex, sizes::Tuple)
linearindex(I::CartesianIndex, ax::MultiIndexAxis)
linearindex(I, nx, nv)

Convert the CartesianIndex I to its linear index on a grid of extents sizes, on the axis ax, or on the nx × nv grid. Inverse of multiindex. An index outside the grid raises a BoundsError.

source
MultiIndexArrays.multiindex — Method
multiindex(i::Integer, sizes::Tuple)
multiindex(i::Integer, ax::MultiIndexAxis)
multiindex(i, nx, nv)

Convert the linear index i to the CartesianIndex it denotes on a grid of extents sizes, on the axis ax, or on the nx × nv grid. The first dimension runs fastest. Inverse of linearindex. An index outside the grid raises a BoundsError.

source
MultiIndexArrays.stencil_indices — Method
stencil_indices(i::Integer, w::Integer, sizes::NTuple{D, Int})
stencil_indices(gt::GridTensor, i::Integer)

The linear indices of the periodic stencil of width w around the linear index i, as a lazy iterator of (2w+1)^D entries on the grid of extents sizes. The offsets run over (-w):w in each direction, the first direction outermost and the last innermost, and each one wraps around the grid, so a neighbour of a node on an edge is a node on the opposite edge. The first dimension of the grid runs fastest, as it does for multiindex. An i outside the grid raises a BoundsError, and a negative w an ArgumentError.

stencil_indices(gt, i) is the stencil of the width and on the grid of the GridTensor gt.

julia> collect(stencil_indices(1, 1, (2, 3))) == [6, 2, 4, 5, 1, 3, 6, 2, 4]
true
source