GradedArrays.jl

Stable Dev Build Status Coverage Code Style Aqua

A Julia package for arrays with graded (blocked) spaces, such as those invariant under group actions. Built on top of, and compatible with, TensorKit.jl.

Support

Flatiron Center for Computational Quantum Physics logo. Flatiron Center for Computational Quantum Physics logo.

GradedArrays.jl is supported by the Flatiron Institute, a division of the Simons Foundation.

Installation instructions

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("GradedArrays")

Examples

A GradedArray is an array over spaces graded by symmetry sectors, and it stores only the blocks the symmetry allows. Build the spaces from sector => multiplicity pairs and pass them to the standard Julia array constructors.

using GradedArrays: U1, dual, gradedrange
g = gradedrange([U1(0) => 1, U1(1) => 2])
a = randn(g, dual(g))
3×3 GradedArray (codomain 2, domain 0):
  Codomain Dim 1: gradedrange([U1(0) => 1, U1(1) => 2])
  Codomain Dim 2: dual(gradedrange([U1(0) => 1, U1(1) => 2]))
3×1 FusedGradedMatrix{Float64, U1, Vector{Float64}, …} with 1 stored block at sectors [U1(0)]:
  Codomain Dim 1: fusedgradedrange([U1(0) => 5, U1(1) => 2, U1(-1) => 2])
  Domain Dim 1:   fusedgradedrange([U1(0) => 1])
  1.3005714164075934
 -1.0104778509625456
  1.4988452954277434
 -0.1151830427171292
  1.2733774256832844
 ───────────────────
   ⋅                
   ⋅                
 ───────────────────
   ⋅                
   ⋅                

dual gives the dual of a space. zeros, ones, and fill work the same way, and allocate only the allowed blocks.

zeros(g, dual(g))
3×3 GradedArray (codomain 2, domain 0):
  Codomain Dim 1: gradedrange([U1(0) => 1, U1(1) => 2])
  Codomain Dim 2: dual(gradedrange([U1(0) => 1, U1(1) => 2]))
3×1 FusedGradedMatrix{Float64, U1, Vector{Float64}, …} with 1 stored block at sectors [U1(0)]:
  Codomain Dim 1: fusedgradedrange([U1(0) => 5, U1(1) => 2, U1(-1) => 2])
  Domain Dim 1:   fusedgradedrange([U1(0) => 1])
 0.0
 0.0
 0.0
 0.0
 0.0
 ───
  ⋅ 
  ⋅ 
 ───
  ⋅ 
  ⋅ 

A GradedArray supports many basic array operations, such as multiplication by a scalar, addition, and permutation of the dimensions.

2 * a
3×3 GradedArray (codomain 2, domain 0):
  Codomain Dim 1: gradedrange([U1(0) => 1, U1(1) => 2])
  Codomain Dim 2: dual(gradedrange([U1(0) => 1, U1(1) => 2]))
3×1 FusedGradedMatrix{Float64, U1, Vector{Float64}, …} with 1 stored block at sectors [U1(0)]:
  Codomain Dim 1: fusedgradedrange([U1(0) => 5, U1(1) => 2, U1(-1) => 2])
  Domain Dim 1:   fusedgradedrange([U1(0) => 1])
  2.601142832815187 
 -2.020955701925091 
  2.9976905908554867
 -0.2303660854342584
  2.5467548513665688
 ───────────────────
   ⋅                
   ⋅                
 ───────────────────
   ⋅                
   ⋅                
b = randn(g, dual(g))
a + b
3×3 GradedArray (codomain 2, domain 0):
  Codomain Dim 1: gradedrange([U1(0) => 1, U1(1) => 2])
  Codomain Dim 2: dual(gradedrange([U1(0) => 1, U1(1) => 2]))
3×1 FusedGradedMatrix{Float64, U1, Vector{Float64}, …} with 1 stored block at sectors [U1(0)]:
  Codomain Dim 1: fusedgradedrange([U1(0) => 5, U1(1) => 2, U1(-1) => 2])
  Domain Dim 1:   fusedgradedrange([U1(0) => 1])
  0.2572864512363342
 -0.9275561061098718
  2.1647761243206336
  1.3994946506058663
  1.563669631579304 
 ───────────────────
   ⋅                
   ⋅                
 ───────────────────
   ⋅                
   ⋅                
permutedims(a, (2, 1))
3×3 GradedArray (codomain 2, domain 0):
  Codomain Dim 1: dual(gradedrange([U1(0) => 1, U1(1) => 2]))
  Codomain Dim 2: gradedrange([U1(0) => 1, U1(1) => 2])
3×1 FusedGradedMatrix{Float64, U1, Vector{Float64}, …} with 1 stored block at sectors [U1(0)]:
  Codomain Dim 1: fusedgradedrange([U1(0) => 5, U1(1) => 2, U1(-1) => 2])
  Domain Dim 1:   fusedgradedrange([U1(0) => 1])
  1.3005714164075934
 -1.0104778509625456
 -0.1151830427171292
  1.4988452954277434
  1.2733774256832844
 ───────────────────
   ⋅                
   ⋅                
 ───────────────────
   ⋅                
   ⋅                

For the symmetries that are available, see Symmetry sectors. For more information on graded spaces and arrays, see Graded arrays.


This page was generated using Literate.jl.