symop.polynomial.kernels.measurements.number.postselect¶
Postselection kernel for polynomial density-state number measurement.
This module implements deterministic (non-sampling) number postselection for polynomial density states.
Given a desired measurement outcome, the kernel projects the input state onto the corresponding number sector and returns the resulting branch, along with its probability.
Both standard number postselection and joint per-port number postselection
are supported. The behavior is selected via
action.resolution.grouping.
Notes
For density states, the probability of a postselected outcome is computed as the trace of the projected density operator,
If the probability is strictly positive, the projected state is normalized to unit trace. If the measurement is destructive, the measured subsystem is discarded by tracing out the selected modes.
If the requested outcome has zero probability, the returned state is
None.
Functions
Postselect a photon-number outcome for a polynomial density state. |
- postselect_number_detector_poly_density(*, state: DensityPolyState, action: PostselectAction, ctx: ApplyContext | None = None) PostselectionResult¶
Postselect a photon-number outcome for a polynomial density state.
- Parameters:
state (
DensityPolyState) – Polynomial density-state wrapper on which postselection is performed.action (
PostselectAction) – Semantic postselect action defining the measurement target, desired outcome, resolution, and whether the measurement is destructive.ctx (
ApplyContext|None) – Optional apply context. Not used by this kernel.
- Returns:
Result containing the requested outcome, its probability, and the corresponding postselected state when the probability is nonzero.
- Return type:
PostselectionResult
- Raises:
TypeError – If joint per-port postselection is requested but the provided outcome is not a
JointOutcome.
Notes
If
action.resolution.groupingisMeasurementGrouppingEnum.JOINT_PORTS, joint per-port postselection is performed. In this case,action.outcomemust be aJointOutcome.Otherwise, standard number postselection is applied, and the outcome is validated using
require_number_outcome().The projection is performed structurally by keeping only those terms in the density polynomial that match the requested number sector.
The probability of the postselected branch is computed as
\[p = \mathrm{Tr}(\rho_{\mathrm{proj}}).\]If
p <= 0, the result containsstate=None.If
p > 0, the projected state is trace-normalized before being returned. Ifaction.destructiveis True, the measured modes are removed via partial trace.