Struct qvnt::operator::Op[][src]

pub struct Op(_);

Implementations

impl Op[src]

pub fn len(&self) -> usize[src]

pub fn clear(&mut 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]

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]

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]

X rotation operator.

Performs phase radians rotation around X axis on a Bloch sphere.

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]

Y rotation operator.

Performs phase radians rotation around Y axis on a Bloch sphere.

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]

Pauli Z operator.

Negate an amplitude of 1-state.

Z |0> = |0>

Z |1> = -|1>

pub fn s(a_mask: usize) -> Self[src]

S operator.

Square root of Z operator.

S |0> = |0>

S |1> = i|1>

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]

Z rotation operator.

Performs phase radians rotation around Z axis on a Bloch sphere.

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]

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]

SWAP gate.

Performs SWAP of 2 qubits’ value.

SWAP |ab> = |ba>

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]

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]

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]

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]

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]

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]

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]

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]

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

impl Debug for Op[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Op[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl Mul<Op> for Op[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: Self) -> Self[src]

Performs the * operation. Read more

impl<'a> Mul<Op> for &'a mut Op[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: Op) -> Self::Output[src]

Performs the * operation. Read more

impl MulAssign<Op> for Op[src]

fn mul_assign(&mut self, rhs: Self)[src]

Performs the *= operation. Read more

impl<'a> MulAssign<Op> for &'a mut Op[src]

fn mul_assign(&mut self, rhs: Op)[src]

Performs the *= operation. Read more

Auto Trait Implementations

impl !RefUnwindSafe for Op

impl Send for Op

impl Sync for Op

impl Unpin for Op

impl !UnwindSafe for Op

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V