paulistrings/channel/
unitary.rs

1//! General unitaries pre-decomposed into Pauli expansions. See §6.
2
3#![allow(unused)]
4
5use super::{Channel, OutputBuffer};
6use num_complex::Complex64;
7
8/// Generic 1-qubit unitary, stored as the Pauli expansion of its
9/// Heisenberg-picture action on `{I, X, Y, Z}` at the support qubit.
10///
11/// `MAX_FANOUT = 4` since each input Pauli on the support can map to a sum
12/// over all four basis Paulis.
13pub struct GeneralUnitary1Q {
14    /// The single qubit this gate acts on.
15    pub support: [u32; 1],
16    /// 4x4 table: rows indexed by input Pauli (`I, X, Z, Y` in symplectic
17    /// order), columns by output Pauli, entries are complex coefficients.
18    pub table: [[Complex64; 4]; 4],
19}
20
21impl Channel<1> for GeneralUnitary1Q {
22    fn max_fanout(&self) -> usize {
23        4
24    }
25
26    fn support(&self) -> &[u32] {
27        &self.support
28    }
29
30    fn apply(
31        &self,
32        _input_x: &[u64; 1],
33        _input_z: &[u64; 1],
34        _coeff: Complex64,
35        _out: &mut OutputBuffer<'_, 1>,
36    ) {
37        todo!("§6: index `table` by input bits at support; emit nonzero output Paulis")
38    }
39}
40
41/// Generic 2-qubit unitary, stored as a 16x16 Pauli-expansion table.
42pub struct GeneralUnitary2Q {
43    /// The two qubits this gate acts on.
44    pub support: [u32; 2],
45    /// 16x16 table: rows indexed by the 4-bit packed input Pauli on the
46    /// two support qubits, columns by the output Pauli, entries are
47    /// complex coefficients.
48    pub table: [[Complex64; 16]; 16],
49}
50
51impl Channel<1> for GeneralUnitary2Q {
52    fn max_fanout(&self) -> usize {
53        16
54    }
55
56    fn support(&self) -> &[u32] {
57        &self.support
58    }
59
60    fn apply(
61        &self,
62        _input_x: &[u64; 1],
63        _input_z: &[u64; 1],
64        _coeff: Complex64,
65        _out: &mut OutputBuffer<'_, 1>,
66    ) {
67        todo!("§6: index `table` by 4 input bits at support; emit nonzero output Paulis")
68    }
69}