quantex v0.1.0 Q

Documentation for Q ( Elixir Quantum module ).

Link to this section Summary

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

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)

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 ]

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 ]

|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)

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 ]

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 ]

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 ]