This package resides in the ITensor/ITensorRegistry
local registry.
In order to install, simply add that registry through your package manager.
This step is only required once.
julia> using Pkg: Pkg
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
or:
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
Then, the package can be added as usual through the package manager:
julia> Pkg.add("NamedDimsArrays")
using NamedDimsArrays: align, dimnames, named, unname
using TensorAlgebra: contract
# Named dimensions
i = named(2, "i")
j = named(2, "j")
k = named(2, "k")
# Arrays with named dimensions
na1 = randn(i, j)
na2 = randn(j, k)
@show dimnames(na1) == ("i", "j")
# Indexing
@show na1[j => 2, i => 1] == na1[1, 2]
# Tensor contraction
na_dest = contract(na1, na2)
@show issetequal(dimnames(na_dest), ("i", "k"))
# `unname` removes the names and returns an `Array`
@show unname(na_dest, (i, k)) ≈ unname(na1) * unname(na2)
# Permute dimensions (like `ITensors.permute`)
na1 = align(na1, (j, i))
@show na1[i => 1, j => 2] == na1[2, 1]
This page was generated using Literate.jl.