use crate::operations::{Define, InvolveQubits, InvolvedQubits, Operate, RoqoqoError, Substitute};
#[cfg(feature = "unstable_operation_definition")]
use crate::{operations::OperateMultiQubit, Circuit};
use std::collections::HashSet;
use super::SupportedVersion;
#[derive(
Debug,
Clone,
PartialEq,
Eq,
roqoqo_derive::SupportedVersion,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct DefinitionFloat {
name: String,
length: usize,
is_output: bool,
}
#[allow(non_upper_case_globals)]
const TAGS_DefinitionFloat: &[&str; 3] = &["Operation", "Definition", "DefinitionFloat"];
impl InvolveQubits for DefinitionFloat {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
super::InvolvedClassical::All(self.name.clone())
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
roqoqo_derive::SupportedVersion,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct DefinitionComplex {
name: String,
length: usize,
is_output: bool,
}
#[allow(non_upper_case_globals)]
const TAGS_DefinitionComplex: &[&str; 3] = &["Operation", "Definition", "DefinitionComplex"];
impl InvolveQubits for DefinitionComplex {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
super::InvolvedClassical::All(self.name.clone())
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
roqoqo_derive::SupportedVersion,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct DefinitionUsize {
name: String,
length: usize,
is_output: bool,
}
#[allow(non_upper_case_globals)]
const TAGS_DefinitionUsize: &[&str; 3] = &["Operation", "Definition", "DefinitionUsize"];
impl InvolveQubits for DefinitionUsize {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
super::InvolvedClassical::All(self.name.clone())
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
roqoqo_derive::SupportedVersion,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct DefinitionBit {
name: String,
length: usize,
is_output: bool,
}
#[allow(non_upper_case_globals)]
const TAGS_DefinitionBit: &[&str; 3] = &["Operation", "Definition", "DefinitionBit"];
impl InvolveQubits for DefinitionBit {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
super::InvolvedClassical::All(self.name.clone())
}
}
#[derive(
Debug,
Clone,
PartialEq,
roqoqo_derive::SupportedVersion,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct InputSymbolic {
name: String,
input: f64,
}
#[allow(non_upper_case_globals)]
const TAGS_InputSymbolic: &[&str; 3] = &["Operation", "Definition", "InputSymbolic"];
impl InvolveQubits for InputSymbolic {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
let mut a: HashSet<(String, usize)> = HashSet::new();
a.insert((self.name.clone(), 0));
super::InvolvedClassical::Set(a)
}
}
#[derive(
Debug,
Clone,
PartialEq,
Eq,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct InputBit {
name: String,
index: usize,
value: bool,
}
impl SupportedVersion for InputBit {
fn minimum_supported_roqoqo_version(&self) -> (u32, u32, u32) {
(1, 1, 0)
}
}
impl super::ImplementedIn1point1 for InputBit {}
#[allow(non_upper_case_globals)]
const TAGS_InputBit: &[&str; 3] = &["Operation", "Definition", "InputBit"];
impl InvolveQubits for InputBit {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
let mut a: HashSet<(String, usize)> = HashSet::new();
a.insert((self.name.clone(), self.index));
super::InvolvedClassical::Set(a)
}
}
#[cfg(feature = "unstable_operation_definition")]
#[derive(
Debug,
Clone,
PartialEq,
roqoqo_derive::OperateMultiQubit,
roqoqo_derive::Operate,
roqoqo_derive::Substitute,
roqoqo_derive::Define,
)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json_schema", derive(schemars::JsonSchema))]
pub struct GateDefinition {
circuit: Circuit,
name: String,
qubits: Vec<usize>,
free_parameters: Vec<String>,
}
#[cfg(feature = "unstable_operation_definition")]
impl super::ImplementedIn1point13 for GateDefinition {}
#[cfg(feature = "unstable_operation_definition")]
impl SupportedVersion for GateDefinition {
fn minimum_supported_roqoqo_version(&self) -> (u32, u32, u32) {
(1, 13, 0)
}
}
#[cfg(feature = "unstable_operation_definition")]
#[allow(non_upper_case_globals)]
const TAGS_GateDefinition: &[&str; 3] = &["Operation", "Definition", "GateDefinition"];
#[cfg(feature = "unstable_operation_definition")]
impl InvolveQubits for GateDefinition {
fn involved_qubits(&self) -> InvolvedQubits {
InvolvedQubits::None
}
fn involved_classical(&self) -> super::InvolvedClassical {
let mut classical_set: HashSet<(String, usize)> = HashSet::new();
for parameter in &self.free_parameters {
classical_set.insert((parameter.to_owned(), 0));
}
super::InvolvedClassical::Set(classical_set)
}
}