Skip to main content

ppvm_traits/traits/branch/
tgate.rs

1// SPDX-FileCopyrightText: 2026 The PPVM Authors
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::config::Config;
5
6/// The non-Clifford `T` gate and its adjoint.
7///
8/// `T = diag(1, e^{iπ/4})`. Implemented by the simulator backends; see
9/// the example in [`ppvm_tableau`](https://docs.rs/ppvm-tableau).
10pub trait TGate<T: Config> {
11    /// Apply `T` (`diag(1, e^{iπ/4})`) to one qubit.
12    fn t(&mut self, addr0: usize);
13    /// Apply `T†` to one qubit.
14    fn t_dag(&mut self, addr0: usize);
15
16    /// Explicit batched `T`.
17    fn t_many(&mut self, targets: &[usize]) {
18        for &q in targets {
19            self.t(q);
20        }
21    }
22
23    /// Explicit batched `T†`.
24    fn t_dag_many(&mut self, targets: &[usize]) {
25        for &q in targets {
26            self.t_dag(q);
27        }
28    }
29}