[−][src]Struct q1tsim::export::LatexExportState
Structure to build up contents of LaTeX export
Struct LatexExportState
is used to build up the matrix containing the
Qcircuit code for the export of a Circuit
to LaTeX.
Methods
impl LatexExportState
[src]
pub fn new(nr_qbits: usize, nr_cbits: usize) -> Self
[src]
Create a new LatexExportState
Create a new LatexExportState
, for a circuit with nr_qbits
quantum
bits and nr_cbits
classical bits.
pub fn reserve(
&mut self,
qbits: &[usize],
cbits: Option<&[usize]>
) -> Result<()>
[src]
&mut self,
qbits: &[usize],
cbits: Option<&[usize]>
) -> Result<()>
Ensure that fields are free.
Ensure that the fields for the bits in qbits
and (optionally) cbits
are currently unoccupied. If not, add a new column to the export.
pub fn start_range_op(
&mut self,
qbits: &[usize],
cbits: Option<&[usize]>
) -> Result<()>
[src]
&mut self,
qbits: &[usize],
cbits: Option<&[usize]>
) -> Result<()>
Ensure that fields are free.
Ensure that the fields for the bits in qbits
and (optionally) cbits
,
as well as all field in the range between the minimum and maximum bit,
are currently unoccupied. If not, add a new column to the export.
pub fn end_range_op(&mut self)
[src]
Mark fields as in use.
Mark the fields in the fields in the range last opened by
start_range_op()
as in use, and close the range.
pub fn set_field(&mut self, bit: usize, contents: String) -> Result<()>
[src]
Set the contents of a field
Set the contents of the field corresponding to bit bit
to the LaTeX
code in contents
.
pub fn set_measurement(
&mut self,
qbit: usize,
cbit: usize,
basis: Option<&str>
) -> Result<()>
[src]
&mut self,
qbit: usize,
cbit: usize,
basis: Option<&str>
) -> Result<()>
Add a measurement
Add a measurement of quantum bit qbit
to classical bit cbit
in basis
basis
to the export. If basis
is None
, no basis string is drawn in
the measurement.
pub fn set_reset(&mut self, qbit: usize) -> Result<()>
[src]
Add a reset
Add the reset of quantum bit qbit
to the export.
pub fn set_condition(
&mut self,
control: &[usize],
target: u64,
qbits: &[usize]
) -> Result<()>
[src]
&mut self,
control: &[usize],
target: u64,
qbits: &[usize]
) -> Result<()>
Add classical control
Add the control of an operation on quantum bits qbits
by classical
bits control to the export state. This function only adds the control
part, the actual quantum operation should be drawn elsewhere. The bits
in control
make up a register, whose value should match target
.
The first bit in control
corresponds to the least significant bit of
target
, the last bit in control
to the most significant bit.
pub fn add_block_gate(&mut self, qbits: &[usize], desc: &str) -> Result<()>
[src]
Add a simple block gate
Add a gate with description desc
operating on qubits qbits
as a
simple box containing the description. If the gate opertes on mutiple
disjoint ranges of qbits, it is drawn using mutiple boxes connected by
wires.
pub fn start_loop(&mut self, count: usize)
[src]
Open a loop
Open a loop of count
ieterations at the current row in the export
state. This loop should later be closed by a call to end_loop()
, at
which point the loop will be added to the export state.
pub fn end_loop(&mut self) -> Result<()>
[src]
Close a loop
Close the loop opened last by a call to start_loop()
.
pub fn add_cds(&mut self, bit: usize, count: usize, label: &str) -> Result<()>
[src]
Add dots
This function adds the string in label
in the middle of the range of
qbits starting at bit
and going count
bits down. This is usually
used to add the dots used to indicate a repeated subcircuit in loops.
pub fn set_barrier(&mut self, qbits: &[usize]) -> Result<()>
[src]
Add a barrier
Add a barrier for the quantum bits in qbits
. Note that the placement
of barriers may sometimes be off because the spacing between elements
is not constant. It may therefore need some manual adjustment.
pub fn code(&self) -> String
[src]
Export to LaTeX
This code exports the matrix that was built up in this state to LaTeX code. It uses the qcircuit package to do so.
pub fn set_controlled(&mut self, controlled: bool) -> bool
[src]
Set whether gates are controlled
This sets the option to draw gates in their normal layout
(controlled = false
) or in their controlled layout (when
controlled = true
). This can make a difference for e.g. the X gate,
which is drawn as a boxed X character normally, but as an exclusive
or symbol (⊕) when used in a CX
gate.
pub fn is_controlled(&self) -> bool
[src]
Return whether gates should currently be drawn normally, or in their controlled form.
pub fn set_expand_composite(&mut self, expand: bool)
[src]
Set whether to expand composite gates.
Set whether composite gates should be drawn as individual components.
If expand
is true
, composite gates are drawn by drawing their
components. If expand
is false, composite gates are drawn as a single
block gate.
pub fn expand_composite(&self) -> bool
[src]
Whether to expand composite gates.
Return whether composite gates should be drawn as individual components
(in which case true
is returned), or as a single, possibly multi-bit,
operation (when the result is false
).
pub fn set_add_init(&mut self, add_init: bool)
[src]
Set whether to add initialization strings
When add_init
is true
, initialization strings are added to the
bits, when false
they are omitted.
Auto Trait Implementations
impl Send for LatexExportState
impl Sync for LatexExportState
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,