qit.utils.tensorbasis

qit.utils.tensorbasis(n, d=None, get_locality=False, only_local=False)

Hermitian tensor-product basis for End(H).

Returns a Hermitian basis for linear operators on the Hilbert space H which shares H’s tensor product structure. The basis elements are tensor products of Gell-Mann matrices (which in the case of qubits are equal to Pauli matrices). The basis elements are normalized such that \(\mathrm{Tr}(b_i^\dagger b_j) = \delta_{ij}\).

Input is either two scalars, n and d, in which case the system consists of n qu(d)its, \(H = C_d^{\otimes n}\), or the vector dim, which contains the dimensions of the individual subsystems: \(H = C_{dim[0]} \otimes ... \otimes C_{dim[n-1]}\).

In addition to expanding Hermitian operators on H, this basis can be multiplied by the imaginary unit to obtain the antihermitian generators of U(prod(dim)).

Parameters
  • n (int, Sequence[int]) – number of subsystems, or if d is None, a dimension vector

  • d (int, None) – dimension of the qudits constituting the subsystems

  • get_locality (bool) – if True, return also the locality of the basis elements

  • only_local (bool) – if True, only return basis elements whose locality==1

Returns

basis elements, locality

Return type

array[array[complex]], array[int]

The second output variable is an integer array denoting the locality of each basis element, i.e. the number of non-identity matrices in the tensor product.