Quantum Fourier Transformation and Phase Estimation

Let's use Yao first

using Yao

Quantum Fourier Transformation

The Quantum Fourier Transformation (QFT) circuit is to repeat two kinds of blocks repeatly:

qft-circuit

The basic building block control phase shift gate is defined as

\[R(k)=\begin{bmatrix} 1 & 0\\ 0 & \exp\left(\frac{2\pi i}{2^k}\right) \end{bmatrix}\]

Let's define block A and block B, block A is actually a control block.

A(i, j) = control(i, j=>shift(2π/(1<<(i-j+1))))
A (generic function with 1 method)

Once you construct the blockl you can inspect its matrix using mat function. Let's construct the circuit in dash box A, and see the matrix of $R_4$ gate.

R4 = A(4, 1)
(n -> control(n, 4, 1 => shift(0.39269908169872414)))

If you have read about preparing GHZ state, you probably know that in Yao, we could just leave the number of qubits, and it will be evaluated when possible.

R4(5)
nqubits: 5
control(4)
└─ (1,) shift(0.39269908169872414)

its matrix will be

mat(R4(5))
32×32 Diagonal{ComplexF64, Vector{ComplexF64}}:
 1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅           1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅               ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im      ⋅              ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅           1.0+0.0im          ⋅    
     ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅          ⋅              ⋅               ⋅              ⋅               ⋅              ⋅               ⋅      0.92388+0.382683im

Then we repeat this control block over and over on different qubits, and put a Hadamard gate to ith qubit to construct i-th B block.

B(n, k) = chain(n, j==k ? put(k=>H) : A(j, k) for j in k:n)
B (generic function with 1 method)

We need to input the total number of qubits n here because we have to iterate through from k-th location to the last.

Now, let's construct the circuit by chaining all the B blocks together

qft(n) = chain(B(n, k) for k in 1:n)
qft(4)
nqubits: 4
chain
├─ chain
│  ├─ put on (1)
│  │  └─ H
│  ├─ control(2)
│  │  └─ (1,) shift(1.5707963267948966)
│  ├─ control(3)
│  │  └─ (1,) shift(0.7853981633974483)
│  └─ control(4)
│     └─ (1,) shift(0.39269908169872414)
├─ chain
│  ├─ put on (2)
│  │  └─ H
│  ├─ control(3)
│  │  └─ (2,) shift(1.5707963267948966)
│  └─ control(4)
│     └─ (2,) shift(0.7853981633974483)
├─ chain
│  ├─ put on (3)
│  │  └─ H
│  └─ control(4)
│     └─ (3,) shift(1.5707963267948966)
└─ chain
   └─ put on (4)
      └─ H

Wrap QFT to an external block

In most cases, functions are enough to wrap quantum circuits, like A and B we defined above, but sometimes, we need to dispatch specialized methods on certain kinds of quantum circuit, or we want to define an external block to export, thus, it's useful to be able to wrap circuit to custom blocks.

First, we define a new type as subtype of PrimitiveBlock since we are not going to use the subblocks of QFT, if you need to use its subblocks, it'd be better to define it under CompositeBlock.

struct QFT <: PrimitiveBlock{2}
    n::Int
end

YaoBlocks.nqudits(q::QFT) = q.n

Now, let's define its circuit

circuit(q::QFT) = qft(q.n)
circuit (generic function with 1 method)

And forward mat to its circuit's matrix

YaoBlocks.mat(::Type{T}, x::QFT) where T = mat(T, circuit(x))

You may notice, it is a little ugly to print QFT at the moment, this is because we print the type summary by default, you can define your own printing by overloading print_block

YaoBlocks.print_block(io::IO, x::QFT) = print(io, "QFT($(x.n))")

Since it is possible to use FFT to simulate the results of QFT (like cheating), we could define our custom apply! method:

using FFTW, LinearAlgebra

function YaoBlocks.apply!(r::ArrayReg, x::QFT)
    α = sqrt(length(statevec(r)))
    invorder!(r)
    lmul!(α, ifft!(statevec(r)))
    return r
end

Now let's check if our apply! method is correct:

r = rand_state(5)
r1 = r |> copy |> QFT(5)
r2 = r |> copy |> circuit(QFT(5))
r1 ≈ r2
true

We can get iQFT (inverse QFT) directly by calling adjoint

QFT(5)'
 [†]QFT(5)

QFT and iQFT are different from FFT and IFFT in three ways,

  1. they are different by a factor of $\sqrt{2^n}$ with $n$ the number of qubits.
  2. the bit numbering will exchange after applying QFT or iQFT.
  3. due to the convention, QFT is more related to IFFT rather than FFT.

Phase Estimation

Since we have QFT and iQFT blocks we can then use them to realize phase estimation circuit, what we want to realize is the following circuit:

phase estimation

First we call Hadamard gates repeatly on first n qubits.

Hadamards(n) = repeat(H, 1:n)
Hadamards (generic function with 1 method)

Then in dashed box B, we have controlled unitaries:

ControlU(n, m, U) = chain(n+m, control(k, n+1:n+m=>matblock(U^(2^(k-1)))) for k in 1:n)
ControlU (generic function with 1 method)

each of them is a U of power $2^{(k-1)}$.

Since we will only apply the qft and Hadamard on first n qubits, we could use Subroutine, which creates a context of a sub-scope of the qubits.

PE(n, m, U) =
    chain(n+m, # total number of the qubits
        subroutine(Hadamards(n), 1:n), # apply H in local scope
        ControlU(n, m, U),
        subroutine(QFT(n)', 1:n))
PE (generic function with 1 method)

we use the first n qubits as the output space to store phase $ϕ$, and the other m qubits as the input state which corresponds to an eigenvector of oracle matrix U.

The subroutine here uses focus! and relax! to manage a local scope of quantum circuit, and only activate the first n qubits while applying the block inside the subroutine context, and the scope will be relax!ed back, after the context. This is equivalent to manually focus! then relax!

fullly activated

r = rand_state(5)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

first 3 qubits activated

focus!(r, 1:3)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 3/5
    nlevel: 2

relax back to the original

relax!(r, 1:3)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

In this way, we will be able to apply small operator directly on the subset of the qubits.

Details about the algorithm can be found here: Quantum Phase Estimation Algorithm

Now let's check the results of our phase estimation.

First we need to set up a unitary with known phase, we set the phase to be 0.75, which is 0.75 * 2^3 == 6 == 0b110 .

N, M = 3, 5
P = eigen(rand_unitary(1<<M)).vectors
θ = Int(0b110) / 1<<N
phases = rand(1<<M)
phases[0b010+1] = θ
U = P * Diagonal(exp.(2π * im * phases)) * P'
32×32 Matrix{ComplexF64}:
 -0.0342104-0.122403im     -0.0958414-0.164054im     0.122046-0.0263991im    0.0470934-0.00812037im     0.06784+0.17487im        -0.073243+0.0920402im    0.0204053+0.123156im      0.0241696+0.0668509im     0.0286554+0.0836411im    0.0615858+0.0143712im    0.0124815+0.112401im      -0.128649-0.0454085im     0.0496692+0.165091im       -0.183672+0.0987576im   -0.0510558+0.0181579im    -0.0765647+0.236811im      -0.148234+0.192701im          0.196-0.0546057im   0.0278439-0.137254im    -0.00269072-0.10753im        0.115473+0.0399776im     0.0647695+0.247883im       -0.106324-0.0442391im    -0.135494+0.195215im       0.247546+0.0888728im    -0.0686987+0.0610131im    0.0258363-0.108358im    -0.0257995-0.0177843im      0.234571-0.298257im   -0.0974636+0.17729im      -0.140219-0.0798399im       0.297439-0.080566im
   0.177468+0.115239im     -0.0536361-0.0330071im   -0.103126-0.114463im     -0.411373+0.0517669im    0.0446526-0.054322im       -0.102417+0.202653im     0.0404184+0.0329603im     -0.163334-0.0974105im       0.27111-0.0143389im     0.291915+0.0492585im     0.123187+0.0184151im     0.0287511-0.0626583im       0.21358-0.0398554im     -0.0987374+0.184805im     -0.215267-0.026448im      0.0435173+0.0150143im     -0.121559-0.0725756im     0.0909775+0.0894337im    0.095861+0.159544im    -0.00140979+0.125338im     -0.0426401+0.11038im      -0.0989923+0.0587558im      -0.107382-0.0112333im     0.282403-0.0108891im      0.209847+0.0864396im    -0.0161318-0.0318963im     0.113705+0.0195006im   -0.0656335-0.0707036im     0.0616609+0.121376im    0.0156331+0.00312655im  -0.0180327+0.00156984im     -0.193585+0.0299819im
  -0.158266+0.0871227im    -0.0484387+0.120824im   -0.0093039-0.277132im    -0.0495179+0.0966236im    0.0240122+0.0189259im      0.0665799-0.0251534im    -0.025481+0.348384im     0.00522179-0.323175im     -0.0371193-0.161904im     0.0351973-0.0573901im    0.0595569-0.076088im      0.0235596-0.0955178im     0.0310448+0.00271345im   0.000587467+0.035899im     0.0494488-0.167581im      -0.211172+0.074054im      -0.051054-0.235253im      0.0811305-0.0277614im   -0.186088+0.0967198im    -0.0506711-0.235839im       0.167692+0.207861im      0.0254901-0.115008im    -0.000740548-0.00228806im  0.00617866-0.192228im     -0.0983185-0.0999563im     0.0519862-0.0941138im    0.0461125+0.202057im    -0.0353302+0.0941481im    0.00820917-0.243627im    0.0448164-0.0311391im     0.126573-0.0661008im       0.180229+0.0775628im
  -0.211462-0.0361087im     -0.047488+0.135407im    -0.101316-0.0287932im    0.0670941+0.0234259im   -0.0233434+0.358166im      -0.0381316+0.114354im    -0.0542808-0.159068im      -0.218328-0.0315302im      -0.15415+0.165599im      0.273328-0.0289im       0.0187694+0.121153im      0.0593454+0.039819im       0.193758+0.0496684im       0.184883+0.0142317im    0.0405775+0.0554818im     0.0758123-0.163048im     -0.0763273-0.0836425im     0.0624749+0.204989im    -0.150582-0.0158301im      0.134961-0.123073im     -0.0840003-0.0342917im    -0.0367901-0.0626232im       0.162695+0.114124im    -0.0997868+0.0298132im    -0.0760407+0.126934im     -0.0956292+0.0227261im     0.191821-0.215067im    -0.0528606+0.0665432im     -0.038403-0.0412987im    0.268824+0.193447im      0.055452+0.122673im        0.023386+0.0800866im
 0.00198166+0.346353im       0.165975-0.0664989im   -0.149159-0.0320062im    -0.113191+0.200004im     0.0603795-0.10504im         0.286423-0.0696352im    -0.107321-0.128768im      0.0310091-0.151367im     -0.0612499-0.183824im    -0.0136968+0.225466im      -0.21667+0.144894im     0.00192085+0.0453155im   -0.00857576-0.103658im      -0.0465493+0.0644936im    -0.158661+0.10755im      -0.0494112-0.218112im     -0.0737215+0.134565im       0.119893+0.0304825im   -0.152794+0.0111035im    -0.0270524+0.1143im       -0.0636777+0.0281257im      0.177017-0.0652074im      0.0677901-0.0856951im   -0.0203974+0.154063im     -0.0934188+0.0581291im     0.0580102+0.0385748im   -0.0896946-0.0337709im     0.212841+0.032334im       0.137814-0.0347868im  -0.0665332+0.242896im    -0.0944231+0.0876928im       0.174811+0.00767477im
  -0.093325+0.254868im     -0.0205943-0.0963991im  -0.0895194-0.131775im     -0.159129-0.0584675im    -0.102193+0.137812im      -0.0925117-0.0690827im    0.0244329-0.204304im      0.0085487+0.147244im     -0.0498699-0.0391043im     0.195731-0.0195446im     0.142595-0.138676im      -0.074623+0.0213217im     -0.187357-0.125048im       -0.120162+0.0470513im     0.223465+0.120079im       0.187272-0.0909387im    -0.0875571-0.114136im      0.0989726-0.195298im     0.018689-0.0613743im      0.216225-0.24246im      0.00783196-0.130751im      -0.228951+0.14423im        0.0402229-0.0738141im     0.028869-0.0270305im    -0.0431566-0.0638685im      0.271619-0.0200722im  -0.00429426+0.160553im     0.0407738-0.112028im      -0.069844+0.0178047im   -0.159243-0.0439017im   -0.0803741+0.0667357im       0.193543-0.118221im
 -0.0933249+0.0662437im    -0.0448519-0.0319483im   -0.218608-0.206856im     0.0994385+0.0400136im   -0.0284712+0.146768im        0.353773+0.0118089im    0.0824821-0.0301444im     0.0177906-0.0224878im    -0.0872636+0.0255343im   -0.0602137-0.062896im    -0.0730114+0.101908im      0.0931343+0.102002im       0.136335+0.0832571im      -0.121249-0.120953im      0.073039-0.0318118im     -0.304409+0.0502227im    0.00743369+0.101295im     -0.0603034+0.0321735im    0.116651+0.0485544im     0.0302176+0.141064im      -0.186967-0.134214im      -0.196116-0.0210851im      -0.109864+0.0779741im    -0.102579+0.0948683im      0.247769-0.171561im       0.317614+0.0578328im    0.0677846+0.0700644im    -0.305208-0.0826643im   -0.00150454+0.0392329im  -0.0714737+0.00724688im   0.0990012-0.0569591im      -0.113844+0.00619413im
  -0.232881-0.00274203im  -0.00985468+0.266988im     0.032434+0.171314im    -0.0977434+0.134725im     -0.147889-0.0909033im     -0.0924923-0.137714im    0.00411937+0.138085im       0.112408-0.132164im      0.0703534-0.0367623im   -0.0477761-0.106569im      0.114293+0.0404439im   -0.00595276+0.038834im       0.120178+0.258763im       -0.217257-0.170096im     0.0809812+0.205008im    -0.00421488-0.160414im      -0.378771+0.20466im       0.0176044-0.0356046im    0.113493+0.15568im        0.215177+0.0693724im    0.00742599-0.0218033im    -0.0251537+0.00362624im    -0.0181795+0.12116im     0.00655843+0.0922231im    -0.0431498-0.0528581im      -0.14336-0.197653im     -0.133153+0.0486946im   0.00727631+0.109709im     -0.0398753+0.0537452im   0.0399332-0.0296036im   -0.0387429+0.0773896im     -0.0312951-0.172045im
 -0.0245244-0.0610516im     -0.233418+0.118619im   -0.0244619-0.123134im     -0.025293+0.234878im     0.0183769-0.0269301im       0.178199-0.0955804im   -0.0683149+0.0626979im     0.0596601+0.0933961im     0.0889833-0.105177im      0.120668+0.0119845im      0.21566+0.0631523im     0.0457643-0.0611825im    -0.0505437-0.0168105im     -0.0382134+0.0549324im   -0.0792073-0.217897im     -0.0210344+0.160644im       0.121738-0.0477931im    -0.0817354+0.302889im     0.267327-0.00988093im    0.0659389-0.192413im       0.195641-0.247065im        0.10714-0.0481766im      0.0763279-0.095044im     -0.145214+0.212543im      -0.156127+0.0269829im    -0.0164908+0.0386839im   -0.0598445-0.0848184im     0.121979-0.113673im      0.0846613+0.276913im   -0.0053771-0.0225919im    0.0501325+0.11428im        0.0303761-0.16233im
   0.149396-0.00836878im    0.0322087-0.113453im   -0.0196472+0.0721119im    -0.115583-0.15425im      -0.142108+0.0145781im      0.0504292-0.172808im     0.0767901-0.0308066im      0.281693-0.18189im      -0.0937763-0.11913im      0.0799642-0.142736im     0.0600999-0.375649im       0.138786-0.00455718im   -0.0208179-0.0540031im      0.0332873-0.11607im     -0.0392967+0.0158869im    -0.0584343+0.00575343im    -0.037447-0.0378495im    -0.0933376+0.153609im     0.026079+0.0634028im     0.0498106-0.0579873im     0.0957929+0.0309505im    -0.0280354+0.155625im       0.0264527-0.0266707im    -0.153201+0.16056im         0.24879+0.0459052im     0.0585744+0.236632im      0.121297-0.00436025im    0.237854+0.215101im     -0.0497383-0.122593im     0.239422+0.144044im    -0.0910124+0.021834im       -0.184825+0.030811im
  -0.134716-0.0947375im     -0.112023-0.140692im    0.0284971+0.153214im      0.026144+0.101595im     0.0896226+0.0758714im      0.0152403-0.233893im      0.134454-0.00345658im    -0.167975-0.221067im       0.128476+0.0924261im     0.188144-0.224918im    0.00639563-0.0866752im     -0.167399+0.264291im      -0.062624-0.201774im      -0.0722784-0.0762817im    0.0341104-0.15103im      -0.0291512+0.0425931im     -0.108045+0.00775908im      -0.1026+0.146396im    -0.125222-0.0925487im    -0.0712777+0.237488im      -0.083218+0.139589im       0.080789+0.141799im        0.227584-0.0244699im     0.034018-0.0641239im    -0.0712149+0.033174im     -0.0814318+0.222559im     -0.149785+0.214im        -0.124385-0.155374im     -0.0199824+0.0726032im   -0.106314+0.076268im    -0.0160268+0.0351174im      0.0609134-0.065321im
 -0.0175454-0.0314239im    -0.0937729-0.0409317im    0.028589-0.191843im     0.0500437+0.336638im      0.174184+0.145775im       -0.102445-0.128687im    -0.0126466+0.00947717im    0.0604028+0.0373493im     0.0953455+0.0794033im   -0.0911652+0.036066im      0.102709+0.0303142im      0.215563-0.336893im       0.068319-0.0168683im     -0.0238959-0.19932im     -0.0436884+0.262435im      0.0964922-0.121826im      0.0799576-0.0301425im    -0.0296523-0.0840184im     0.13186-0.158649im      -0.178711+0.0586465im     -0.152247+0.135857im      0.0229656+0.0522692im      -0.144093-0.0534308im   -0.0594798-0.0164771im    -0.0506448+0.0621923im    -0.0528597+0.173305im      0.153015+0.253644im     0.0348185+0.0620307im     -0.232621+0.125006im    0.0641324+0.129747im    -0.0691481-0.103179im        0.102223-0.00961942im
  -0.118485-0.0518264im      0.184254-0.104668im    -0.266854+0.157431im     -0.157417+0.0621705im    -0.163231-0.1078im       -0.00178575+0.104085im     -0.144009+0.114685im     -0.0871329+0.0611838im     -0.130806+0.0267888im    -0.212513+0.0727808im    0.0875916+0.067877im      -0.131729+0.0183963im     0.0367659+0.0698007im     -0.0190348+0.0129584im    0.0216715-0.128367im      0.0792116-0.0635539im      0.109403-0.140846im    -0.00481669+0.0366754im    0.128168+0.0704811im     0.0606688-0.0309823im     -0.127964-0.120819im       0.275109+0.188074im        0.128442-0.0302527im     0.047098-0.0315022im     0.0468542-0.00340488im    0.0251698+0.165896im      0.106377+0.234033im     -0.150029-0.0198356im     0.0940485-0.0392876im    0.358143-0.118954im     -0.161365-0.18848im         0.134834-0.115612im
  0.0109681+0.0427369im      0.111889+0.028952im     0.145373+0.101699im    -0.0340253-0.114712im    -0.0978875+0.0923449im    -0.00246545+0.0078505im    0.0981159+0.109855im      0.0104481+0.0245292im      0.201064-0.315124im    -0.0251262-0.108933im     -0.131758+0.0522085im    -0.0494273-0.164165im       0.105982-0.200915im       0.0905616-0.233875im     -0.218633-0.0904333im     -0.177675-0.0727387im      0.111923-0.0173554im    -0.0440524+0.0607445im   -0.115458-0.142704im        0.26977-0.0160888im     -0.135419-0.100934im     -0.0261183+0.107062im      -0.0954651-0.0836674im    0.0419898-0.00635516im   -0.0631385-0.0134238im    -0.0441334-0.195786im       0.15375-0.13822im     -0.0705294-0.282896im      -0.210229-0.0632096im    0.050958+0.0948591im   -0.0579609-0.0830749im       0.115941-0.223197im
  0.0138788-0.0683679im      0.179198+0.138317im    -0.023961-0.0597643im     0.138404+0.294479im    -0.0731674+0.000741816im    0.0219077-0.0574676im     0.126092-0.208759im     -0.0907731+0.0889371im      0.186082-0.0137243im     0.065046+0.0536041im    0.0596696-0.113285im      0.0416202+0.207116im      0.0107486+0.112219im       -0.264758-0.169906im     0.0863677-0.224362im      0.0104254-0.0307267im      0.229771-0.186296im      0.0429427-0.0670193im  -0.0351685+0.0999143im    -0.0510786-0.0212042im     0.0148656+0.0430405im     0.0669805+0.0592658im       -0.12752-0.0189078im   -0.0360873+0.0133303im      0.117255+0.19161im       0.0257248-0.25258im      -0.159716-0.0840157im    0.0416656-0.0669029im     -0.104808-0.168274im    0.0809871+0.036558im     -0.282293+0.0500396im      -0.017292+0.236564im
   -0.11137+0.0334079im       0.16266-0.0748106im    0.143507-0.124756im     -0.146217-0.0643289im   0.00693941+0.290075im        0.124555-0.146625im     -0.213076-0.012827im     0.00863272+0.00412182im    -0.184797+0.0833053im   -0.0312652-0.0894253im     0.124416-0.151083im      -0.140452+0.0505256im     0.0382531-0.13982im        0.0283796-0.074414im      0.101412-0.0574072im     0.0518418-0.0417572im      0.135114-0.0224583im      0.181306-0.0612947im    0.124309+0.00800778im   -0.0195547+0.412262im       0.310466-0.0614613im      0.171774-0.0253695im      -0.217882-0.0379021im    0.0778348+0.00331596im  -0.00739903+0.0460865im     -0.118832-0.228938im      0.161796-0.0363892im   -0.0444827+0.0709571im     0.0995149+0.0839326im  -0.0262759+0.0529115im    0.0983266+0.000295883im   -0.0434306-0.0900466im
 -0.0225132+0.0275103im     -0.250979+0.030117im    0.0518739+0.072536im    -0.0543033-0.0703355im    0.0260712-0.0299543im     -0.0938373-0.136566im      0.196065-0.0386257im   -0.00776221-0.019598im      -0.086877-0.118012im      -0.15008-0.198374im     0.0203619+0.423809im      -0.105189+0.00384543im    0.0767538-0.00927281im     0.0195216+0.121303im    -0.0133891-0.12695im       -0.204754-0.316828im       0.148153-0.266609im       0.203704-0.119407im     0.132558-0.0751493im     -0.148179+0.0485856im     0.0325305-0.116773im     -0.0883629+0.164703im       0.0964941+0.103286im    -0.0276473-0.0501895im      0.111337+0.0966861im   0.000407616+0.0176209im    0.0219618+0.0347105im     0.180029+0.166299im     0.00961134-0.0354099im  -0.0928421-0.0178093im   -0.0455798+0.142971im      -0.0978296+0.00761482im
  -0.136153+0.0652007im     -0.217312-0.153106im     0.133472+0.158668im      0.109102-0.103041im     -0.235018+0.0770631im       0.114939+0.109359im     -0.111161+0.0308088im     -0.258265-0.0726903im      0.153366-0.103094im    -0.0630582-0.0101219im     0.200949-0.135211im      0.0405366-0.0113144im     -0.179742-0.0403199im      -0.232659+0.124341im      -0.03804+0.00858683im    -0.010471-0.120913im    -0.00802068-0.062324im      0.0159376-0.12119im     0.0349322+0.136636im      -0.242277-0.00480179im    -0.165025-0.0824998im    -0.0547196-0.0610894im      -0.138236+0.133344im    -0.0468512+0.0109872im     -0.143547-0.14704im       0.0053712+0.0400225im   -0.0463358-0.190597im      0.134182-0.0146439im     0.0530114+0.0573485im    0.124592+0.250562im     0.0542195-0.290774im      -0.0294986+0.0133928im
 -0.0544433-0.154216im       0.052321-0.129691im    -0.124319-0.106922im    -0.0852476-0.107367im     -0.152871-0.0895716im       0.129913+0.0306776im   -0.0138351-0.259133im      -0.117745-0.148063im       0.175028+0.120727im     -0.200564-0.118362im    -0.0276461+0.0761517im      0.223839-0.0704975im    0.00784933-0.130383im        0.123417+0.0538306im     0.133105-0.0321053im     -0.130418+0.0495048im     -0.250894-0.0302059im   -0.00534081-0.0399974im     0.11077-0.355188im     0.00739096-0.131938im        0.15701+0.105112im      0.0145396-0.172465im       -0.115682+0.0542727im    0.0529961-0.0172992im    -0.0878378+0.253603im      0.0442703-0.0809635im    -0.166801+0.0202078im   -0.0351773+0.00201674im     0.060511-0.0259995im    0.102524+0.0157882im    -0.185273-0.0387118im     -0.0995955-0.209439im
    0.14931+0.0772049im     0.0826214+0.208445im   0.00244597+0.0146257im    0.0211509-0.220219im     0.0739054+0.0941185im       0.275642-0.0992082im   -0.0783494-0.0115im        -0.136847+0.0685624im       0.18504+0.0255702im   -0.0676452-0.0441574im   -0.0348411+0.15913im       -0.297297+0.0900254im     -0.140655+0.0941053im     -0.0374651-0.10661im      0.0409017+0.0113671im      0.138261+0.00133515im    -0.134175-0.0737892im    -0.0251125+0.0971267im    0.225215-0.0235708im      0.084542-0.220929im      -0.058832+0.173621im       0.160193-0.0987702im      -0.196603+0.136866im     0.0509302+0.0097488im     0.0549158-0.0487702im     -0.102079+0.156435im       0.20761+0.206771im      0.191808-0.12195im      -0.0829087-0.125751im    -0.066808+0.0823419im    0.0913428+0.0767894im     -0.0836961+0.113441im
  0.0627667-0.069103im       -0.15003-0.185988im    -0.323936-0.133363im     0.0768045-0.142533im     -0.122893+0.142659im      -0.0411155-0.00894454im  0.00355279+0.262123im     -0.0790918+0.061493im       0.142298-0.251861im     -0.132337+0.059829im    -0.0265723+0.00865491im   -0.0443921+0.146172im       0.155866+0.0435503im     -0.0352978-0.0378622im     0.143233+0.170247im       0.052845+0.0172494im    -0.0893193-0.0561149im      -0.03456-0.108698im    0.0416164-0.060398im      0.0390731+0.0563591im     0.0145397+0.00272332im     0.160358+0.127746im       0.0709783-0.387279im     0.0434965+0.0944744im     -0.162711+0.155689im    -0.00700297-0.0170812im    -0.100891-0.126742im    -0.0158326+0.0860963im     -0.138278-0.0125238im  -0.0189256+0.0106696im     0.209739+0.106693im       -0.123899+0.202896im
 -0.0070593-0.119989im      0.0997542+0.0484994im   0.0830324-0.111365im    -0.0632039+0.0271819im     -0.11432+0.0419032im      0.0618689-0.0659974im     0.239822+0.141155im      0.0917934+0.0531888im     0.0684001-0.0112791im   -0.0292543-0.0566823im    -0.117756+0.14036im       0.0280347-0.0878174im     -0.172638-0.138456im      0.00517351+0.0599139im      0.22602-0.185668im       0.191019+0.0886823im     -0.110432-0.00395743im    0.0224385-0.24333im    0.00690852+0.0565466im     -0.062726+0.0385162im      -0.23117+0.067574im     -0.0785314-0.241562im        0.229723-0.2367im      -0.0170312+0.0956895im      0.210421-0.146677im      -0.135451-0.102281im      0.159504-0.0346457im    0.0154056+0.00832318im     0.184748+0.184252im      0.20094+0.173782im    -0.0651071+0.12954im        0.0366851+0.0120871im
  -0.199732-0.0179608im     0.0593181+0.0366109im    0.216035+0.0269992im   -0.0498875-0.0437481im    0.0734627-0.310159im        0.272107-0.0493707im     0.069901+0.0882529im     -0.104493+0.108314im       -0.10783+0.183317im      0.152088+0.0489127im    -0.102018-0.0168446im     0.0171921-0.0723807im    -0.0740052-0.0150589im      -0.272946+0.0658233im    -0.071254+0.115979im     -0.0900334-0.0126368im    -0.0625811-0.0134053im      -0.22995-0.0315023im    0.028786-0.197282im     -0.0747237-0.044071im      0.0552351-0.205924im     -0.0799492+0.221009im      -0.0699706-0.182439im      0.180285-0.135063im      -0.065814+0.118662im      0.0273664-0.0434926im       0.1334-0.00879531im  -0.0751408+0.101772im     -0.0432518-0.0677377im    0.220009+0.0799374im     0.139987+0.210767im      -0.0120094+0.12731im
   0.132446-0.0858669im    -0.0755927-0.0449863im   -0.125212-0.101772im     0.0274597-0.156594im    -0.0101711+0.109141im       0.0982222-0.0119912im     0.142869-0.118839im     0.00235607+0.0883735im   -0.00565323+0.00458858im  -0.0720203-0.0934615im     0.142089-0.106664im       0.131964-0.149352im     0.00592377+0.240066im       -0.127325-0.208993im    0.00175689-0.00347576im    -0.136153+0.0353379im     0.0091137+0.0956034im     0.0246843+0.101324im   -0.0896883+0.132559im     -0.0360022+0.0308113im    -0.0924892-0.154878im       0.145354-0.0949541im       0.168258+0.0231382im     0.444899-0.325389im     -0.0714524-0.00475056im     -0.05329+0.0677115im      0.09016-0.0870896im     0.144997+0.0768308im      0.153027-0.0107417im   -0.132109+0.0369088im    -0.131877+0.141526im        0.207783-0.0884174im
  -0.105191+0.0467303im     -0.202663-0.0965834im  -0.0424303-0.173442im      0.134404+0.05037im     0.00798149-0.128807im      -0.0411108+0.128043im     -0.159304+0.0235981im      0.108849+0.108959im      -0.176556+0.0251137im    -0.128627-0.0350502im  -0.00190413-0.0123609im     -0.151163+0.28376im       0.0215757-0.104187im       -0.027484-0.00377037im  -0.0101308+0.0287808im    -0.0120447-0.00973784im   -0.0452881+0.0750725im      0.022155+0.379172im    0.0879025-0.112104im     -0.0504388-0.014772im     -0.0430782+0.101378im      -0.263557-0.0701922im      0.0608517-0.186917im      0.175747-0.108148im       0.145255-0.0895712im     -0.165827-0.260728im     0.0342473+0.0557503im     0.241982-0.0230016im     -0.154051-0.02803im     0.0789039+0.0855741im    -0.183769-0.174506im     -0.00437812-0.00903655im
 -0.0144478+0.111539im      -0.181575-0.0356256im   0.0864216+0.110326im     0.0986641+0.0800326im    0.0701272+0.090377im        0.155869+0.0314046im    0.0693191-0.255728im       0.262092-0.10975im        0.151771-0.111423im    -0.0102713+0.0952394im    -0.122431+0.100754im        0.11469+0.149099im      0.0698467-0.0125545im     -0.0663884-0.096686im     0.0392356+0.193356im       0.130646+0.15415im      -0.0257474-0.127667im     -0.0321405-0.133229im   0.00424872+0.0672377im    -0.0482265-0.00722594im     0.165535-0.0546024im   0.000731299+0.0903122im        0.24345+0.0775339im    0.0936021-0.0498655im    0.00900025+0.155254im      -0.102742-0.115301im      0.221112+0.0672517im    0.0375109-0.198689im       0.192485-0.0845353im      0.1769-0.192571im      0.214051-0.248764im      -0.0294341-0.0558735im
  -0.035823-0.0814438im     0.0403346+0.0601367im  -0.0293825+0.0173506im     0.135271+0.0679222im   -0.0793997+0.203507im       0.0104234-0.123191im     0.0925152+0.0289176im       0.29584+0.0803359im      0.104372+0.261332im     -0.182444+0.115417im    0.00745925+0.0548453im     -0.120843-0.182093im     -0.0771633-0.190203im    -0.000684674+0.278945im     -0.099372-0.018403im     -0.0699455-0.196658im      -0.158048+0.0234895im    0.00217506+0.0848117im  -0.0395636+0.298852im      0.0646439-0.0724345im      0.251309-0.0596044im     0.0474718+0.0366687im       0.090293-0.03955im       0.201433-0.0516816im    -0.0165478+0.0431855im      0.113949+0.0636108im   -0.0624418-0.0201825im    -0.151264-0.132182im      -0.147884-0.0376704im  -0.0473434+0.190945im    -0.0637686-0.135084im       -0.155005+0.132614im
  -0.382882-0.090547im       0.173856-0.226184im   -0.0950698-0.0593887im    0.0728296-0.11108im        0.22848-0.0564601im     -0.0203806-0.0598193im      0.08055+0.131393im     -0.0166299+0.0922754im    -0.0975125-0.0829049im     0.196855-0.0671964im    0.0835507+0.111404im       0.211035-0.067891im     -0.0554036+0.0557808im       0.116787+0.0204638im   -0.0207659+0.0361758im     0.0056097+0.00883494im   -0.0443505+0.0872795im    -0.0092193-0.037298im   0.00876371+0.123469im      0.0275478-0.0367358im    -0.0744226+0.0680951im       0.21994+0.13795im      -0.00610532+0.0552229im   -0.0995727-0.110886im     -0.0296257-0.0338264im     0.0639278-0.169236im     0.0567121+0.0314692im     0.284923-0.284082im        0.09533+0.0112637im  -0.0955988-0.00860884im   -0.117838-0.0595694im      -0.346613+0.0565434im
    0.13674-0.120331im      0.0336938-0.0126541im   -0.012276-0.0328262im   -0.0941256-0.0740709im     0.144692+0.0277857im      -0.112929-0.0565441im     0.142213-0.0153966im     -0.129066+0.140821im       0.147133+0.0198503im     -0.10676+0.102902im     0.0401436-0.0569464im     0.0677062+0.0486925im      0.084649-0.238281im      -0.0377975+0.0181801im     0.159288+0.265977im      -0.112583-0.190373im     -0.0303575-0.093438im     -0.0849826+0.29616im     -0.106228+0.1239im        -0.175618-0.0221387im     0.0200658-0.193469im     -0.0121553-0.0298525im      -0.101656-0.0352171im    -0.211369+0.111852im      -0.074589-0.257782im      -0.125378-0.143029im    0.00164316+0.187695im    -0.0624763-0.049186im       0.297124-0.240261im    0.0461775-0.0567394im   -0.0219576+0.120274im      0.00652194-0.0498747im
   0.117971-0.0268739im    -0.0366908+0.104111im    -0.062831-0.0942026im  -0.00882565-0.0871596im    -0.137564+0.0780311im      -0.169065+0.0684188im    -0.161485-0.0454788im      0.212081+0.108321im     -0.0239907+0.0276127im      0.27032-0.218697im     -0.064195+0.214243im       -0.10745+0.0668526im      0.112336-0.213194im       -0.244016-0.126234im     -0.187167-0.0926935im    -0.0590381+0.0894806im    -0.0713609+0.179132im      -0.042896-0.178411im   -0.0533249-0.0419589im    -0.0985495+0.0459136im     0.0051982-0.135244im      0.0782409-0.14888im       -0.0748115-0.0131156im   -0.0880514-0.050459im      -0.320188-0.050687im      0.0891408+0.0839995im    0.0276036+0.161318im     0.0612388+0.0680793im     0.0960476-0.0502592im    0.165155-0.0853965im    -0.181119-0.0699012im      -0.104992+0.179889im
   0.072241-0.232035im     -0.0389855-0.0582294im   -0.046754+0.0140167im   -0.0655278-0.0532739im     0.101253-0.0309673im       0.252751-0.0194839im    0.0779391-0.186223im     -0.0503874-0.0288694im     0.0312424+0.0496234im    0.0741641-0.0743593im    0.0792891-0.141015im      -0.156787-0.0751599im    0.00818338+0.270575im       -0.078777+0.219585im      -0.11039+0.0570345im     -0.163518-0.152609im      0.0952293+0.0553341im      0.181293-0.13697im     -0.253198-0.0955339im      0.183207-0.0359418im   0.000796747-0.0409735im   -0.00181953-0.144313im        0.099033-0.229191im     -0.126326+0.173633im     -0.0370757-0.0599502im     -0.211098-0.0943144im    0.0950367+0.214083im      0.029767+0.0190648im     -0.144408+0.126025im   0.00302446-0.145753im    -0.0125183-0.240995im      -0.0723706+0.0638116im
  -0.174412-0.118301im      -0.106668+0.228102im    -0.238926-0.140553im    -0.0892195-0.144515im     -0.193653-0.0102101im      -0.118662-0.110884im    -0.0255499-0.0161339im    -0.0746536+0.034508im      0.0295307+0.0876755im     0.146183+0.133452im     -0.140119-0.106173im      0.0388799+0.0657206im     -0.218608-0.185473im      -0.0679552-0.0779719im    -0.222055+0.125971im      -0.175269-0.181816im       0.240205+0.151432im     -0.0984172-0.132205im     0.175966+7.92594e-5im    -0.107282-0.110526im     0.00529517+0.212716im       0.142986-0.0207535im       0.173253+0.0650358im    0.0180321+0.073914im       0.201401+0.0443296im     -0.113835-0.0729845im    0.0636801-0.0737719im   -0.0474127+0.0281959im     0.0360054-0.0551892im   -0.116885-0.0845661im     0.127674-0.0733382im      0.0663265-0.123532im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
    -0.1171190899190381 + 0.04159058117256059im
   -0.06918239303459657 - 0.19513381333554264im
   0.060960704844146625 - 0.03161686300110028im
    0.16717062808681601 + 0.20003973892085972im
    0.03854872084669234 - 0.027740973594870842im
   0.023769816728651923 - 0.08847050951490297im
   -0.01924276186083642 - 0.01969325846018184im
   -0.14648543300715958 + 0.149320583633348im
  -0.025877332672025622 - 0.03476620530512601im
  0.0040945879399939475 - 0.02952064472065529im
   -0.09505106479810947 + 0.14806111972739364im
     0.2212109295951793 - 0.21806628668906064im
      0.152847472995947 - 0.10529581836594673im
      0.319475030161258 + 0.0im
   0.024492398358458584 - 0.1812854964465718im
    0.07045582532020914 - 0.13895164634655988im
   -0.11448897413656528 - 0.29151701460423546im
   -0.22525102765130076 - 0.1501404047842784im
    0.04091949109557339 + 0.07846294813661053im
     0.1761293023035637 - 0.0193931230579072im
   0.024239052591388408 + 0.0835822870065917im
 -0.0058169525547485616 - 0.12934903176946894im
     0.1675760501725024 + 0.07271972039739291im
   0.009513022840077084 + 0.08919603207466582im
   -0.13400055169236932 + 0.10638900304615093im
   -0.06633351705535144 + 0.09085987328469029im
   -0.16289104409474855 - 0.13386305825804032im
   0.013803541936904994 + 0.14226436868876027im
      0.197741968381358 + 0.1825330502587514im
 -0.0038794438391045226 - 0.09396644306289424im
   -0.03361126589969321 - 0.1383339479073053im
    0.06487671420459476 - 0.02203036414729309im

In the phase estimation process, we will feed the state to circuit and measure the first n qubits processed by iQFT.

r = join(ArrayReg(psi), zero_state(N))
r |> PE(N, M, U)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 8/8
    nlevel: 2

Since our phase can be represented by 3 qubits precisely, we only need to measure once

results = measure(r, 1:N; nshots=1)
1-element Vector{DitStr{2, 3, Int64}}:
 011 ₍₂₎

Recall that our QFT's bit numbering is reversed, let's reverse it back

using BitBasis
estimated_phase = bfloat(results[]; nbits=N)
0.75

the phase is exactly 0.75!


This page was generated using Literate.jl.