quantex v0.1.0 Q
Documentation for Q ( Elixir Quantum module ).
Link to this section Summary
Functions
Controlled NOT gate
Cut qbit
Hadamard gate
|0> qubit = ( 1, 0 )
|1> qubit = ( 0, 1 )
X gate
Y gate
Z gate
Link to this section Functions
Link to this function
cnot(qbit1, qbit2)
Controlled NOT gate.
Examples
iex> Q.cnot( Q.q0, Q.q0 ).array # |00>
[ [ 1, 0 ], [ 0, 0 ] ]
iex> Q.cnot( Q.q0, Q.q1 ).array # |01>
[ [ 0, 1 ], [ 0, 0 ] ]
iex> Q.cnot( Q.q1, Q.q0 ).array # |11>
[ [ 0, 0 ], [ 0, 1 ] ]
iex> Q.cnot( Q.q1, Q.q1 ).array # |10>
[ [ 0, 0 ], [ 1, 0 ] ]
Link to this function
cnot_matrix()
Link to this function
complex_add(a, b)
Link to this function
complex_dot(array1, array2)
Link to this function
complex_dot_vector(xm, ym)
Link to this function
complex_mult(a, b)
Link to this function
cut(qbit, no)
Cut qbit.
Examples
iex> Q.cut( Numexy.new( [ Q.q0.array, Q.q1.array ] ), 0 ).array
[ 1, 0 ]
iex> Q.cut( Numexy.new( [ Q.q0.array, Q.q1.array ] ), 1 ).array
[ 0, 1 ]
Link to this function
h(qbit)
Hadamard gate.
Examples
iex> Q.h( Q.q0 ).array
[ 1 / Math.sqrt( 2 ) * 1, 1 / Math.sqrt( 2 ) * 1 ]
iex> Q.h( Q.q1 ).array
[ 1 / Math.sqrt( 2 ) * 1, 1 / Math.sqrt( 2 ) * -1 ]
iex> ( Q.h( Q.q0 ) |> Q.h ).array
[ 1, 0 ]
iex> ( Q.h( Q.q1 ) |> Q.h ).array
[ 0, 1 ]
iex> ( Numexy.new( [ Q.q0.array, Q.q1.array ] ) |> Q.cut( 0 ) |> Q.h |> Q.x |> Q.h ).array
[ 1, 0 ]
iex> ( Numexy.new( [ Q.q0.array, Q.q1.array ] ) |> Q.cut( 1 ) |> Q.h |> Q.x |> Q.h ).array
[ 0, -1 ]
Link to this function
h_matrix()
|0> qubit = ( 1, 0 )
Examples
iex> Q.q0.array
[ 1, 0 ]
|1> qubit = ( 0, 1 )
Examples
iex> Q.q1.array
[ 0, 1 ]
Link to this function
tensordot(array1, array2)
Link to this function
to_bit(value)
Link to this function
x(qbit)
X gate.
Examples
iex> Q.x( Q.q0 ).array
[ 0, 1 ]
iex> Q.x( Q.q1 ).array
[ 1, 0 ]
iex> ( Q.z( Q.q1 ) |> Q.x ).array
[ -1, 0 ]
iex> ( Q.z( Q.q1 ) |> Q.x |> Q.x ).array
[ 0, -1 ]
iex> ( Q.h( Q.q0 ) |> Q.x ).array
[ 1 / Math.sqrt( 2 ) * 1, 1 / Math.sqrt( 2 ) * 1 ]
iex> ( Q.h( Q.q1 ) |> Q.x ).array
[ 1 / Math.sqrt( 2 ) * -1, 1 / Math.sqrt( 2 ) * 1 ]
Link to this function
x_matrix()
Link to this function
y(qbit)
Y gate.
Examples
iex> Q.y( Q.q0 ).array
[ 0, ComplexNum.new( 0, 1 ) ]
iex> Q.y( Q.q1 ).array
[ ComplexNum.new( 0, -1 ), 0 ]
iex> ( Q.y( Q.q0 ) |> Q.y ).array
[ 1, 0 ]
iex> ( Q.y( Q.q1 ) |> Q.y ).array
[ 0, 1 ]
Link to this function
y_matrix()
Link to this function
z(qbit)
Z gate.
Examples
iex> Q.z( Q.q0 ).array
[ 1, 0 ]
iex> Q.z( Q.q1 ).array
[ 0, -1 ]
iex> ( Q.h( Q.q0 ) |> Q.z ).array
[ 1 / Math.sqrt( 2 ) * 1, 1 / Math.sqrt( 2 ) * -1 ]
iex> ( Q.h( Q.q1 ) |> Q.z ).array
[ 1 / Math.sqrt( 2 ) * 1, 1 / Math.sqrt( 2 ) * 1 ]
Link to this function