Skip to main content

quantrs2_ml/torchquantum/layer/
tqcxcxcxlayer_traits.rs

1//! # TQCXCXCXLayer - Trait Implementations
2//!
3//! This module contains trait implementations for `TQCXCXCXLayer`.
4//!
5//! ## Implemented Traits
6//!
7//! - `TQModule`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use crate::error::{MLError, Result};
12use crate::torchquantum::{
13    gates::{
14        TQHadamard, TQPauliX, TQPauliY, TQPauliZ, TQRx, TQRy, TQRz, TQCNOT, TQCRX, TQCRY, TQCRZ,
15        TQCZ, TQRXX, TQRYY, TQRZX, TQRZZ, TQS, TQSWAP, TQSX, TQT,
16    },
17    CType, TQDevice, TQModule, TQOperator, TQParameter,
18};
19
20use super::functions::{create_single_qubit_gate, create_two_qubit_gate};
21use super::types::TQCXCXCXLayer;
22
23impl TQModule for TQCXCXCXLayer {
24    fn forward(&mut self, qdev: &mut TQDevice) -> Result<()> {
25        for _ in 0..3 {
26            for i in 0..(self.n_wires - 1) {
27                let mut gate = TQCNOT::new();
28                gate.apply(qdev, &[i, i + 1])?;
29            }
30        }
31        Ok(())
32    }
33    fn parameters(&self) -> Vec<TQParameter> {
34        Vec::new()
35    }
36    fn n_wires(&self) -> Option<usize> {
37        Some(self.n_wires)
38    }
39    fn set_n_wires(&mut self, n_wires: usize) {
40        self.n_wires = n_wires;
41    }
42    fn is_static_mode(&self) -> bool {
43        self.static_mode
44    }
45    fn static_on(&mut self) {
46        self.static_mode = true;
47    }
48    fn static_off(&mut self) {
49        self.static_mode = false;
50    }
51    fn name(&self) -> &str {
52        "CXCXCXLayer"
53    }
54}