Class QuantumReg
In: rquantum.rb
Parent: Object

QuantumReg represents register of several qubits. It‘s also checks the consitency of Universal control and Controlled not gates (searching the loops - when state of one qubit depends on second and vice versa).

 r = QuantumReg.new 2
 r.reset
 r.hadamard 0
 r.not 1
 r.pr

 0.707106781186547+0.0i       |01>
 0.707106781186547+0.0i       |11>

QuantumReg class (like Qubit) has also methods generated from the classes with compute method from Gates module. It always takes one parameter - number of registry qubit.

Methods

controlled_not   controlled_u   measure   new   pr   reset  

Public Class methods

It‘s generating new registry with given length.

Public Instance methods

Controlled not gate. Takes the control and the target qubit indexes as parameters.

Controlled universal gate. Takes the control and the target qubit indexes and the 2x2 matrix as parameters.

Measure state of range of the qubits. With no parameters it‘s measure state of all qubits. With one parameter - measure state of the qubit with given index. With two parameters - measure state of qubit with indexes begining with first and ending with last parameter.

Prints register state. See the warning in the pr method in Qubit class.

 q = QuantumReg.new 2
 q.reset
 q.pr

 1+0i       |00>

Resets state of the registry.

[Validate]