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

Matrices use to simulate gates.

Methods

C   R  

Constants

NOT = Matrix[ [0, 1], [1, 0]   Simple NOT gate
H = 1/Math.sqrt(2) * Matrix[ [1, 1], [1, -1]   Hadamard gate
Z = Matrix[ [1, 0], [0, -1]   PauliZ gate
Y = Z * NOT   PauliY gate

Public Class methods

Controlled-U gate

 Gates::Matrices.C Matrix[[1.5, 2.5], [3.5, 4.5]] # -> Matrix[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1.5, 2.5], [0, 0, 3.5, 4.5]]

Phase shifter gate

 Gates::Matrices.R 0.2    # -> Matrix[[1, 0], [0, Complex(0.309016994374947, 0.951056516295154)]]

[Validate]