Class Gates::ControlledNot
In: rquantum.rb
Parent: Object

Controlled not gate - if the control qubit (passed as the parameter) equals 1, then it‘s works as the simple Not gate. Otherwise nothing is done.

 control = Qubit.new
 target = Qubit.new
 control.reset
 target.reset

 gate = Gates::ControlledNot.new control
 gate.compute target.to_vector   # -> Vector[1+0i, 0i]
 control.not
 gate.compute target.to_vector   # -> Vector[0i, 1+0i]
 control.hadamard
 gate.compute target.to_vector   # -> Vector[0.707106781186547+0.0i, -0.707106781186547+0.0i]

Methods

compute   new  

Public Class methods

Creates new Controlled Not gate using given control qubit.

Public Instance methods

Takes vector with two complex numbers (amplitudes), perform gate operation and returns new vector.

[Validate]