pub struct Program { /* private fields */ }Expand description
Qubits, bits, registers and operations of a dynamic circuit.
Implementations§
Source§impl Program
impl Program
Sourcepub fn to_qasm3(&self) -> Result<String>
pub fn to_qasm3(&self) -> Result<String>
The program as OpenQASM 3 (standard gates, with ctrl @ for gates
with more controls; rxx, ryy, rzz are defined in the header).
Exact including relative phases of controlled gates.
Sourcepub fn to_qasm2(&self) -> Result<String>
pub fn to_qasm2(&self) -> Result<String>
The program as OpenQASM 2.0: one quantum register q, the
classical registers of the program (renamed with a trailing _
where a name is taken or reserved). Conditions must compare a whole
register for equality and may not be nested, as OpenQASM 2 requires.
Source§impl Program
impl Program
Sourcepub fn new(n_qubits: usize, n_bits: usize) -> Result<Self>
pub fn new(n_qubits: usize, n_bits: usize) -> Result<Self>
Empty program with one register q of n_qubits qubits and one
register c of n_bits bits (if any).
Sourcepub fn add_qubit_register(
&mut self,
name: &str,
size: usize,
) -> Result<&Register>
pub fn add_qubit_register( &mut self, name: &str, size: usize, ) -> Result<&Register>
Append a quantum register; its qubits follow the existing ones.
Sourcepub fn add_bit_register(&mut self, name: &str, size: usize) -> Result<&Register>
pub fn add_bit_register(&mut self, name: &str, size: usize) -> Result<&Register>
Append a classical register; its bits follow the existing ones.
Sourcepub fn from_circuit(
circuit: &Circuit,
theta: &[f64],
measure_all: bool,
) -> Result<Self>
pub fn from_circuit( circuit: &Circuit, theta: &[f64], measure_all: bool, ) -> Result<Self>
The program of circuit (parameters bound to theta), with every
qubit measured into the bit of the same index if measure_all.
pub fn n_qubits(&self) -> usize
pub fn n_bits(&self) -> usize
pub fn qubit_registers(&self) -> &[Register]
pub fn bit_registers(&self) -> &[Register]
pub fn operations(&self) -> &[Operation]
pub fn is_empty(&self) -> bool
Sourcepub fn is_unitary(&self) -> bool
pub fn is_unitary(&self) -> bool
Whether the program has only gates.
Sourcepub fn to_circuit(&self) -> Result<Circuit>
pub fn to_circuit(&self) -> Result<Circuit>
The gates as a Circuit; an error if the program measures,
resets or branches.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Program
impl<'de> Deserialize<'de> for Program
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Program
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
impl UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.