pytenet.block_sparse_util

utility functions for handling block-sparse tensors with quantum number conservation.

Functions

block_sparse_eigh(a, q0)

Compute the block-wise diagonalization of a Hermitian matrix a, taking the block sparsity structure dictated by quantum numbers into account (that is, a[i, j] can only be non-zero if q0[i] == q0[j]).

block_sparse_qr(a, q0, q1)

Compute the block-wise QR decompositions of a matrix, taking block sparsity structure dictated by quantum numbers into account (that is, a[i, j] can only be non-zero if q0[i] == q1[j]).

block_sparse_svd(a, q0, q1)

Compute the block-wise SVD of a block-sparse matrix.

common_qnumbers(qnums0, qnums1)

Find common quantum numbers between two lists of quantum numbers.

enforce_qsparsity(a, qnums)

Enforce sparsity pattern on a based on quantum numbers.

is_qsparse(a, qnums)

Test whether sparsity structure of a matches quantum numbers, i.e., if the quantum numbers corresponding to non-zero entries in a sum to zero.

qnumber_flatten(qnums)

Combine quantum numbers into a single vector.

qnumber_outer_sum(qnums)

Compute the sum of all combinations of quantum numbers in qnums, and return the result as a tensor.

slice_with_qnumber(qn, qnums)

Assuming the quantum numbers are sorted, find the first and last indices at which a given quantum number appears.

sort_by_qnumbers(a, q0, q1)

Sorts a matrix according to quantum numbers.