Channel

Trait Channel 

Source
pub trait Channel<const W: usize>: Send + Sync {
    // Required methods
    fn max_fanout(&self) -> usize;
    fn support(&self) -> &[u32];
    fn apply(
        &self,
        input_x: &[u64; W],
        input_z: &[u64; W],
        coeff: Complex64,
        out: &mut OutputBuffer<'_, W>,
    );

    // Provided method
    fn apply_adjoint(
        &self,
        input_x: &[u64; W],
        input_z: &[u64; W],
        coeff: Complex64,
        out: &mut OutputBuffer<'_, W>,
    ) { ... }
}
Expand description

Anything that maps a Pauli string to a small weighted sum of Pauli strings.

Channel::max_fanout is a method (not an associated const) so the trait stays dyn-compatible — Circuit stores Box<dyn Channel<W>> to keep the channel set open for user extensions. For built-in channels the returned value is a compile-time constant so the engine still gets constant-folded buffer sizing once the concrete type is in hand.

See the module-level docs for an impl Channel example.

Required Methods§

Source

fn max_fanout(&self) -> usize

Maximum number of output terms produced per input term. Used by the engine to size the scratch buffer up-front.

Source

fn support(&self) -> &[u32]

Qubits this channel acts on. Outputs differ from inputs only at these bit positions; the engine uses this for bucket layout (§5).

Source

fn apply( &self, input_x: &[u64; W], input_z: &[u64; W], coeff: Complex64, out: &mut OutputBuffer<'_, W>, )

Apply the channel to a single input term, writing outputs to out.

Provided Methods§

Source

fn apply_adjoint( &self, input_x: &[u64; W], input_z: &[u64; W], coeff: Complex64, out: &mut OutputBuffer<'_, W>, )

Apply the channel’s adjoint to a single input term, writing outputs to out. Used by the engine in Direction::Heisenberg mode for backpropagating observables.

The default implementation is self.apply(...), i.e. assumes the channel is self-adjoint. Channels that are not self-adjoint (PauliRotation, Clifford1Q::s) override this. The design doc (§8) does not pin down a mechanism; this is the v0.1 convention.

Implementors§

Source§

impl Channel<1> for GeneralUnitary1Q

Source§

impl Channel<1> for GeneralUnitary2Q

Source§

impl<const W: usize> Channel<W> for Clifford1Q

Source§

impl<const W: usize> Channel<W> for Clifford2Q

Source§

impl<const W: usize> Channel<W> for IdentityChannel

Source§

impl<const W: usize> Channel<W> for AmplitudeDamping

Source§

impl<const W: usize> Channel<W> for Dephasing

Source§

impl<const W: usize> Channel<W> for Depolarizing

Source§

impl<const W: usize> Channel<W> for PauliRotation<W>