GTorlai / PastaQ.jl

Package for Simulation, Tomography and Analysis of Quantum Computers
Apache License 2.0
145 stars 23 forks source link

Remove prepX gates #128

Closed GTorlai closed 4 years ago

GTorlai commented 4 years ago

Do QR decomposition of a set of single-qubit input states and build preparation gates at the start of getsamples.

mtfishman commented 4 years ago

Here is an example of doing a "full" QR:

julia> v = [0.1; 0.2]
2-element Array{Float64,1}:
 0.1
 0.2

julia> normalize!(v)
2-element Array{Float64,1}:
 0.44721359549995787
 0.8944271909999157

julia> Q,R = qr(v)
LinearAlgebra.QRCompactWY{Float64,Array{Float64,2}}
Q factor:
2×2 LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}:
 -0.447214  -0.894427
 -0.894427   0.447214
R factor:
1×1 Array{Float64,2}:
 -0.9999999999999999

julia> Q*Matrix(I, 2, 2)*R[1]
2×2 Array{Float64,2}:
 0.447214   0.894427
 0.894427  -0.447214