Macro qip::wrap_and_invert [−][src]
macro_rules! wrap_and_invert {
(pub $newfunc : ident [$($typetail : tt) *] ($arg : ident : $argtype : ident),
pub $newinvert : ident, $($tail : tt) *) => { ... };
($newfunc : ident [$($typetail : tt) *] ($arg : ident : $argtype : ident), pub
$newinvert : ident, $($tail : tt) *) => { ... };
(pub $newfunc : ident [$($typetail : tt) *] ($arg : ident : $argtype : ident),
$newinvert : ident, $($tail : tt) *) => { ... };
($newfunc : ident [$($typetail : tt) *] ($arg : ident : $argtype : ident),
$newinvert : ident, $($tail : tt) *) => { ... };
(pub $newfunc : ident($arg : ident : $argtype : ident), pub $newinvert :
ident, $($tail : tt) *) => { ... };
($newfunc : ident($arg : ident : $argtype : ident), pub $newinvert : ident,
$($tail : tt) *) => { ... };
(pub $newfunc : ident($arg : ident : $argtype : ident), $newinvert : ident,
$($tail : tt) *) => { ... };
($newfunc : ident($arg : ident : $argtype : ident), $newinvert : ident,
$($tail : tt) *) => { ... };
(pub $newfunc : ident, pub $newinvert : ident, $($tail : tt) *) => { ... };
($newfunc : ident, pub $newinvert : ident, $($tail : tt) *) => { ... };
(pub $newfunc : ident, $newinvert : ident, $($tail : tt) *) => { ... };
($newfunc : ident, $newinvert : ident, $($tail : tt) *) => { ... };
}
Expand description
Wrap a function to create a version compatible with program!
as well as an inverse which is
also compatible.
Example
use qip::*;
let n = 3;
let mut b = OpBuilder::new();
let ra = b.register(n)?;
let rb = b.register(n)?;
wrap_and_invert!(wrap_cy, inv_cy, UnitaryBuilder::cy, ra, rb);
let (ra, rb) = program!(&mut b, ra, rb;
wrap_cy ra, rb[2];
inv_cy ra, rb[2];
)?;
let r = b.merge(vec![ra, rb])?;