MultidimensionalTools.jl Documentation

Adding MultidimensionalTools.jl

julia> using Pkg

julia> Pkg.add("MultidimensionalTools")
   Updating registry at `~/.julia/registries/General`
  Resolving package versions...
  Installed MultidimensionalTools ─ v0.1.0
Updating `~/work/MultidimensionalTools.jl/MultidimensionalTools.jl/docs/Project.toml`
  [9aeeebde] ~ MultidimensionalTools v0.1.0 `~/work/MultidimensionalTools.jl/MultidimensionalTools.jl` ⇒ v0.1.0
Updating `~/work/MultidimensionalTools.jl/MultidimensionalTools.jl/docs/Manifest.toml`
  [9aeeebde] ~ MultidimensionalTools v0.1.0 `~/work/MultidimensionalTools.jl/MultidimensionalTools.jl` ⇒ v0.1.0

Documentation

Main.MultidimensionalTools.append_n_timesMethod

Repeats a specified value n many times along the specified dimension. If no fill_elem is given, and the element type of the matrix is a number, fills with zero.

julia> A = rand(Int8, 2, 2)
2×2 Array{Int8,2}:
  28  23
 -47  54

julia> append_n_times(A, 2, Int8(3), dims = 1) # repeat the value 3 twice along the first dimension
4×2 Array{Int8,2}:
  28  23
 -47  54
   3   3
   3   3
source
Main.MultidimensionalTools.expand_as_requiredMethod
expand_as_required(M::AbstractArray{T, N}, expand_by::T, inds::AbstractIndexOrIndices{N})

Given indices, expand_as_required will fill in a matrix with expand_by where needed if such indices are not currently accessible. If no expand_by is given, and the element type of the matrix is a number, fills with zero.

julia> A = rand(Int8, 2, 2)
2×2 Array{Int8,2}:
 -96   83
 -94  -39

julia> expand_as_required(A, zero(Int8), [(1, 1), (2, 2), (3, 3)])
3×3 Array{Int8,2}:
 -96   83  0
 -94  -39  0
   0    0  0
source
Main.MultidimensionalTools.expanded_adjacenciesMethod
expanded_adjacencies(M::Array{T, N}, expand_by::T, idx::AbstractIndex{N})

expanded_adjacencies will get all adjacencies of an index in the matrix M, given that the matrix is infinitely expanding by a single element beyond the specified M. See also adjacencies and expand_as_required. If no expand_by is given, and the element type of the matrix is a number, fills with zero.

source
Main.MultidimensionalTools.expanded_n_adjacent_toMethod
expanded_n_adjacent_to(M::AbstractArray{T, N}, expand_by::T, idx::AbstractIndex{N}, adj_elem::T)

Given a matrix M, counts the number of adjacent elements to index idx that are exactly the adj_elem, expanding the matrix if needed (see expanded_adjacencies). If no expand_by is given, and the element type of the matrix is a number, fills with zero.

source
Main.MultidimensionalTools.extrema_indicesMethod
extrema_indices(I::AbstractIndices{N}) -> NTuple{N, NTuple{N, Integer}}
extrema_indices(i::AbstractIndex{N}...) -> NTuple{N, NTuple{N, Integer}}
extrema_indices(A::AbstractArray{T, N}...) -> NTuple{N, NTuple{N, Integer}}

Given indices or arrays, returns an NTuple. Each element in the NTuple represents a (min, max) tuple for each dimension.

julia> T = [(3, 1), (4, 5), (6, 2), (1, 1)]
4-element Array{Tuple{Int64,Int64},1}:
 (3, 1)
 (4, 5)
 (6, 2)
 (1, 1)
 
julia> extrema_indices(T)
1×2 Array{Tuple{Int64,Int64},2}:
(1, 6)  (1, 5)

julia> # that is, the (min, max) for dim 2 is (1, 5); etc.
source
Main.MultidimensionalTools.get_directionsMethod

Returns an array of tuples of directions.

    get_directions(dim::Integer; include_zero::Bool = false) -> Array{NTuple{N, Integer}, 1}

julia> get_directions(3)
27-element Array{Tuple{Int64,Int64,Int64},1}:
 (-1, -1, -1)
 (0, -1, -1)
 (1, -1, -1)
 (-1, 0, -1)
 (0, 0, -1)
 (1, 0, -1)
 (-1, 1, -1)
 (0, 1, -1)
 (1, 1, -1)
 (-1, -1, 0)
 (0, -1, 0)
 (1, -1, 0)
 (-1, 0, 0)
 (0, 0, 0)
 (1, 0, 0)
 (-1, 1, 0)
 (0, 1, 0)
 (1, 1, 0)
 (-1, -1, 1)
 (0, -1, 1)
 (1, -1, 1)
 (-1, 0, 1)
 (0, 0, 1)
 (1, 0, 1)
 (-1, 1, 1)
 (0, 1, 1)
 (1, 1, 1)
source
Main.MultidimensionalTools.global_adjacenciesMethod
global_adjacencies(M::AbstractArray{T}, idx::AbstractIndex{N}, ignored_elem::T)

Using global_adjacencies_indices, returns the elements of each globally adjacent index. This function is mainly used for global_n_adjacent_to.

source
Main.MultidimensionalTools.global_adjacencies_indicesMethod
global_adjacencies(M::AbstractArray{T, N}, idx::AbstractIndex{N}, ignored_elem::T)

Returns the "globally" adjacent indices in arbitrary positions in the cardinal directions from a specified index in matrix M, ignoring certain adjacent elements (i.e., skipping over them).

source
Main.MultidimensionalTools.global_n_adjacent_toMethod
global_n_adjacent_to(M::AbstractArray{T, N},idx::AbstractIndex{N}, adj_elem::T, ignored_elem::T) where {N, T}

Given a matrix M, counts the number of adjacent elements to index idx that are exactly the adj_elem, skipping over certain elements if needed (see expanded_adjacencies).

source
Main.MultidimensionalTools.n_adjacenciesMethod
n_adjacencies(dim::Integer) -> Integer
n_adjacencies(M::AbstractArray{T, N}) -> Integer
n_adjacencies(I::AbstractIndexOrIndices{T, N}) -> Integer

Given a matrix or dimension, returns the number of elements adjacent to any given element in an infinite lattice/matrix (i.e., not including edges). For edges, see adjacencies).

source
Main.MultidimensionalTools.n_adjacent_toMethod
n_adjacent_to(M::AbstractArray{T, N}, idx::AbstractIndex{N}, adj_elem::T)

Given a matrix M, counts the number of adjacent elements to index idx that are exactly the adj_elem.

source
Main.MultidimensionalTools.promote_to_3DMethod
promote_to_3D(M::AbstractArray{T, N}, fill_elem::T)
promote_to_3D(M::AbstractArray{T, N}) where T <: Number

A simple, self-evident wrapper for promote_to_nD. No fill_elem assumes that the value is zero (if it can be).

source
Main.MultidimensionalTools.promote_to_nDMethod
function promote_to_nD(M::AbstractArray{T, N}, n::Integer, fill_elem::T)

Assumes the given matrix M is an (n - 1) dimensional slice of an n-dimensional structure, and fills in the array to n dimensions with fill_elem. If no fill_elem is given, and the element type of the matrix is a number, fills with zero.

source
Main.MultidimensionalTools.tryindexMethod
tryindex(M::AbstractArray{T, N}, inds::AbstractIndex{N}}...)
tryindex(M::AbstractArray{T, N}, inds::AbstractIndices{N}})

For each index specified, gets the index or missing if the index is unavailable.

source

Index