project_to_qubit_subspace

Model.project_to_qubit_subspace(unitary, only_diagonal=False)

Project an operator or batch of operators into the qubit subspace.

The projection uses the cached qubit-subspace basis indices derived from the model’s static Hamiltonian. For batched inputs, the last one or two axes are interpreted as Hilbert-space axes.

Parameters:
  • unitary (ndarray | Array) – Operator array in the full Hilbert space.

  • only_diagonal (bool) – If True, treat the last axis as a diagonal only and return the projected diagonal entries without adding a second matrix axis.

Return type:

ndarray | Array

Returns:

Operator represented in the tensor-product qubit subspace.