Struct qvnt::operator::Op [−][src]
pub struct Op(_);
Implementations
impl Op
[src]
impl Op
[src]pub fn len(&self) -> usize
[src]
pub fn clear(&mut self)
[src]
pub fn id() -> Self
[src]
pub fn id() -> Self
[src]Identity operator.
For any quantum state |q>, identity operator does not change state.
I |q> = |q>
pub fn c(self, c_mask: usize) -> Self
[src]
pub fn c(self, c_mask: usize) -> Self
[src]Controlled version of operator.
Change the operator to one controlled by given qubits.
use qvnt::prelude::*; // Get *X* Pauli operator, aka *NOT* gate, acting on first qubit. let usual_op = Op::x(0b001); // Get this operator, controlled by second and third qubit. // This operator is the Toffoli gate, *aka* CCNot gate. // Previous *usual_op* operator is consumed. let contr_op = usual_op.c(0b110);
pub fn x(a_mask: usize) -> Self
[src]
pub fn x(a_mask: usize) -> Self
[src]Pauli X operator, aka NOT gate.
Performs negation for given qubits.
X |0> = |1>
X |1> = |0>
pub fn rx(phase: f64, a_mask: usize) -> Self
[src]
pub fn rx(phase: f64, a_mask: usize) -> Self
[src]X rotation operator.
Performs phase radians rotation around X axis on a Bloch sphere.
pub fn rxx(phase: f64, ab_mask: usize) -> Self
[src]
pub fn rxx(phase: f64, ab_mask: usize) -> Self
[src]Ising XX coupling gate.
Performs phase radians rotation around XX axis on 2-qubit Bloch spheres.
pub fn y(a_mask: usize) -> Self
[src]
pub fn ry(phase: f64, a_mask: usize) -> Self
[src]
pub fn ry(phase: f64, a_mask: usize) -> Self
[src]Y rotation operator.
Performs phase radians rotation around Y axis on a Bloch sphere.
pub fn ryy(phase: f64, ab_mask: usize) -> Self
[src]
pub fn ryy(phase: f64, ab_mask: usize) -> Self
[src]Ising YY coupling gate.
Performs phase radians rotation around YY axis on 2-qubit Bloch spheres.
pub fn z(a_mask: usize) -> Self
[src]
pub fn z(a_mask: usize) -> Self
[src]Pauli Z operator.
Negate an amplitude of 1-state.
Z |0> = |0>
Z |1> = -|1>
pub fn t(a_mask: usize) -> Self
[src]
pub fn t(a_mask: usize) -> Self
[src]S operator.
Fourth root of Z operator.
T |0> = |0>
T |1> = (1+i)/sqrt(2) |1>
pub fn rz(phase: f64, a_mask: usize) -> Self
[src]
pub fn rz(phase: f64, a_mask: usize) -> Self
[src]Z rotation operator.
Performs phase radians rotation around Z axis on a Bloch sphere.
pub fn rzz(phase: f64, ab_mask: usize) -> Self
[src]
pub fn rzz(phase: f64, ab_mask: usize) -> Self
[src]Ising ZZ coupling gate.
Performs phase radians rotation around ZZ axis on 2-qubit Bloch spheres.
pub fn phi(angles_vec: Vec<(f64, usize)>) -> Self
[src]
pub fn phi(angles_vec: Vec<(f64, usize)>) -> Self
[src]Phase shift operator.
Performs phase shift for a range of given qubits by corresponding phase.
use qvnt::prelude::*; use std::f64::consts::PI; // Take a third root of *Z* gate. let z_pow_a = Op::phi(vec![(PI / 3., 0b1)]); // Equivalent to Op::z(0b1). let z = Op::phi(vec![(PI, 0b1)]);
pub fn swap(ab_mask: usize) -> Self
[src]
pub fn swap(ab_mask: usize) -> Self
[src]SWAP gate.
Performs SWAP of 2 qubits’ value.
SWAP |ab> = |ba>
pub fn sqrt_swap(ab_mask: usize) -> Self
[src]
pub fn sqrt_swap(ab_mask: usize) -> Self
[src]Square root of SWAP gate.
Performs a “half” SWAP of 2 qubits’ value. This gate could couple qubits.
sqrt(SWAP) * sqrt(SWAP) |ab> = |ba>
use qvnt::prelude::*; use consts::*; // sqrt(SWAP) gate's matrix representation: assert_eq!( Op::sqrt_swap(0b11).matrix_t::<4>(), [ [_1, _0, _0, _0], [_0, 0.5 * (_1 + _i), 0.5 * (_1 - _i), _0], [_0, 0.5 * (_1 - _i), 0.5 * (_1 + _i), _0], [_0, _0, _0, _1]] );
pub fn i_swap(ab_mask: usize) -> Self
[src]
pub fn i_swap(ab_mask: usize) -> Self
[src]iSWAP gate.
Perform SWAP of 2 qubits’ value, multiplying bu i if qubits are not equals.
iSWAP |00> = |00>
iSWAP |01> = i |01>
iSWAP |10> = i |10>
iSWAP |11> = |11>
pub fn sqrt_i_swap(ab_mask: usize) -> Self
[src]
pub fn sqrt_i_swap(ab_mask: usize) -> Self
[src]Square root of iSWAP gate.
Performs a “half” iSWAP of 2 qubits’ value. This gate could couple qubits.
sqrt(iSWAP) * sqrt(iSWAP) |ab> = iSWAP |ab>
use qvnt::prelude::*; use consts::*; // sqrt(iSWAP) gate's matrix representation: assert_eq!( Op::sqrt_swap(0b11).matrix_t::<4>(), [ [_1, _0, _0, _0], [_0, SQRT_1_2 * _1, SQRT_1_2 * _i, _0], [_0, SQRT_1_2 * _i, SQRT_1_2 * _1, _0], [_0, _0, _0, _1]] );
pub fn h(a_mask: usize) -> Self
[src]
pub fn h(a_mask: usize) -> Self
[src]Hadamard gate.
Performs Hadamard transform on a given qubits. This is the simplest operation that create a superposition from a pure state |i>
H |0> = |+> = ( |0> + |1> ) / sqrt(2)
H |1> = |-> = ( |0> - |1> ) / sqrt(2)
pub fn u1(lam: f64, a_mask: usize) -> Self
[src]
pub fn u1(lam: f64, a_mask: usize) -> Self
[src]U1(lam) gate.
First universal operator. Equivalent to RZ and U3(0,0,lam).
pub fn u2(phi: f64, lam: f64, a_mask: usize) -> Self
[src]
pub fn u2(phi: f64, lam: f64, a_mask: usize) -> Self
[src]U2(phi,lam) gate.
Second universal operator. Equivalent to U3(PI/2, phi, lam)
pub fn u3(the: f64, phi: f64, lam: f64, a_mask: usize) -> Self
[src]
pub fn u3(the: f64, phi: f64, lam: f64, a_mask: usize) -> Self
[src]U3(the,phi,lam) gate.
Third universal operator.
3 parameters are enough to describe any unitary operator. All gates could be expressed in term of U3 up to a phase factor.
X = i U3(PI,PI,0)
Y = i U3(PI,0,0)
Z = i U3(0,0,PI)
Z^a = i U3(0,0,PI*a)
pub fn qft(a_mask: usize) -> Self
[src]
pub fn qft(a_mask: usize) -> Self
[src]Discrete Fourier transform for the quantum state’s amplitudes.
Fourier transform with factor 1/sqrt(N). This transform keeps the norm of vector, so it could be applied as unitary operator. It use the technique of fast fourier transform and have O(n*log(n)) time complexity.
Fourier transform on a single qubit is just a Hadamard gate.
pub fn qft_swapped(a_mask: usize) -> Self
[src]
pub fn qft_swapped(a_mask: usize) -> Self
[src]Discrete Fourier transform with qubits’ swap
QFT is differ from real DFT by a bit order of amplitudes indices. qft_swapped is a natural version of DFT.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,