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§
Sourcefn max_fanout(&self) -> usize
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.
Provided Methods§
Sourcefn apply_adjoint(
&self,
input_x: &[u64; W],
input_z: &[u64; W],
coeff: Complex64,
out: &mut OutputBuffer<'_, W>,
)
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.