triqs.operators.util.extractors.block_matrix_from_op

triqs.operators.util.extractors.block_matrix_from_op()

Dispatched C++ function(s).

[1] (h: Operator,
     gf_struct: [tuple[str, int]],
     ignore_irrelevant: bool = False)
  -> ndarray[ndarray[float | complex, 2], 1]

Convert a block-diagonal quadratic operator into its block-matrix representation.

Assumes that \(\hat{h}\) has the form

\[\hat{h} = \sum_{\sigma ij} h_{\sigma ij} \hat{c}_{\sigma, i}^\dagger \hat{c}_{\sigma, j} \; ,\]

where the first element of each canonical operator’s index is interpreted as the block label \(\sigma\) (a string) and the second element as the in-block integer index \(i\).

If a term that is not of this form is encountered, an exception is thrown unless ignore_irrelevant is true, in which case the offending term is silently skipped.

Parameters:
hOperator

Many-body operator \(\hat{h}\).

gf_struct[tuple[str, int]]

Block structure specifying the block labels and the size of each block.

ignore_irrelevantbool

If true, terms that do not match the expected form are skipped instead of triggering an exception.

Returns:
ndarray[ndarray[float | complex, 2], 1]

One matrix per block, packaged as a one-dimensional array of matrices.