ITensorBase.jl is supported by the Flatiron Institute, a division of the Simons Foundation.
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="git@github.com: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("ITensorBase")Load the package, along with a factorization from MatrixAlgebraKit.jl.
using ITensorBase: Index
using MatrixAlgebraKit: qr_compactAn Index labels one dimension of a tensor and carries its length. Each call makes a new,
distinct index, so a tensor identifies its dimensions by index rather than by position.
i = Index(2)
j = Index(2)
k = Index(2)Make a random ITensor with indices i and j.
a = randn(i, j)Read off an element by giving each index a value with i[value]. The indices can be given
in any order, since elements are looked up by index, not by position.
a[j[2], i[1]]Contract a with another tensor over their shared index j. j is summed over and the
result keeps the remaining indices i and k.
b = randn(j, k)
a * bAdd two tensors. They are matched up by index, so a and c don't need their indices in
the same order.
c = randn(j, i)
a + cFactorize a over index i into a q with orthonormal columns and an upper-triangular
r. The factors share a new index that qr_compact introduces.
q, r = qr_compact(a, (i,))Contracting the factors back together recovers a.
q * rThis page was generated using Literate.jl.