symmray documentationΒΆ
symmray provides block-sparse arrays with abelian symmetries and fermionic
signs. Its arrays follow the NumPy interface where possible and can store blocks
using NumPy, PyTorch, JAX, or another
autoray backend.
import symmray as sr
# some U(1) indices
a, b, c, d, e = [
sr.utils.rand_index("U1", size, dual=False, seed=seed)
for seed, size in enumerate((4, 6, 8, 5, 7))
]
# some fermionic arrays
X = sr.utils.get_rand(
"U1",
shape=(a, b, c.conj()),
fermionic=True,
seed=6,
)
Y = sr.utils.get_rand(
"U1",
shape=(c, d.conj(), e.conj()),
fermionic=True,
seed=7,
)
# contract them
Z = sr.einsum("abc,cde->abde", X, Y)
# fuse into a matrix
matrix = Z.reshape((4 * 6, 5 * 7))
# decompose
U, s, VH = sr.linalg.svd(matrix)
print(U)
# U1FermionicArray(ndim=2, charge=0, indices=[
# (24 = 2+4+6+6+4+2 : +[-2,-1,0,1,2,3])
# -2 ; (2) : [(-1, -1)]
# -1 ; (2+2) : [(-1, 0),(0, -1)]
# 0 ; (2+2+2) : [(-1, 1),(0, 0),(1, -1)]
# 1 ; (2+2+2) : [(0, 1),(1, 0),(2, -1)]
# 2 ; (2+2) : [(1, 1),(2, 0)]
# 3 ; (2) : [(2, 1)]
# (23 = 2+4+5+6+4+2 : -[-2,-1,0,1,2,3])
# ], num_blocks=6, backend=numpy, dtype=float64)
Use the getting-started guide for a short introduction. The later guides describe the array model, storage layouts, fermionic signs, operators, and tensor-network helpers.
Guides
Examples