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.324152+0.0409237im      0.1528+0.16565im       -0.248069-0.0422669im   -0.0628846-0.119249im   -0.0627318+0.147966im     -0.00908889+0.0429079im     0.217598+0.0626606im   -0.00217119+0.118209im     0.0693207+0.229198im       0.106096+0.214995im     -0.00265037+0.205894im     -0.0956252-0.0547794im    0.00857364-0.0427712im    -0.0899292+0.0113011im       0.17625+0.0520977im  -0.0474446-0.100732im       0.14328+0.018359im       0.202753+0.013906im       0.111896-0.194706im    -0.00495604-0.201362im     0.129557-0.0904539im    -0.0917621-0.123279im       0.167727+0.0634704im    -0.0162711+0.0191841im   -0.0804045-0.0581301im     0.0235674-0.180825im       0.215101+0.00707814im    0.0417578-0.0868855im   -0.0918025-0.223534im      -0.0576385+0.115923im     0.145933-0.0414373im   -0.00911751+0.103885im
   0.183298+0.0797065im   0.0832985+0.0677503im     -0.152891-0.102169im      0.152658-0.0811141im   0.0727272+0.0513984im      -0.105504+0.335119im     0.0201974-0.0330449im      0.238698-0.280569im    -0.0158822+0.155934im      0.0180546-0.0859787im     -0.0184685-0.0401806im      0.232854-0.0175645im     0.0388468+0.185318im      -0.054166-0.126692im     -0.0686973-0.0434506im    0.013626+0.0934891im   -0.0877238+0.0849322im    -0.0791718-0.0809654im     -0.014135-0.0631809im    -0.0967865-0.0603937im  -0.0802205-0.137462im       0.107698-0.330588im      0.0773172+0.140752im      0.0433919+0.0364417im     -0.12006+0.0490883im      0.201918-0.156581im      -0.101769+0.0942766im    -0.0282059-0.0164834im   -0.0183214+0.0404476im      0.0846607+0.209413im   -0.0525112+0.0356622im     0.0538748-0.273151im
 -0.0254429+0.0751182im   -0.357063+0.079936im      -0.128238+0.26774im       0.180393-0.102503im    -0.158262+0.227622im         0.17973+0.0337271im    -0.014368-0.055682im       0.059548-0.0198374im    0.0056534-0.126295im      0.0608662+0.115944im      -0.0486669+0.0929372im     0.0211014-0.0663156im    0.00298506+0.215144im     -0.0162777+0.0701911im     0.0092733+0.152211im     0.109998+0.0411112im   -0.0620735-0.0853356im      0.165257-0.010226im       -0.21144-0.053645im       0.116807-0.0441516im  -0.0386963-0.203968im     -0.0609971+0.0990437im      0.161861+0.111442im      -0.268091+0.130525im     -0.107398-0.17754im        0.113423+0.0852125im     -0.142633+0.0236392im    -0.0375456+0.0673093im    0.0648229+0.128919im       0.0192724-0.256205im   -0.0974784-0.00602606im    -0.027914+0.0230266im
   0.029744+0.173921im   -0.0172528-0.0243667im      0.053659-0.0811667im    -0.347852+0.149222im   0.00888071-0.0686005im     -0.0952092-0.0764373im    -0.083061+0.061395im     -0.0336589+0.0350676im   -0.0695017+0.195834im      0.0619475+0.0930077im     -0.0346543+0.00516897im     0.186289+0.076499im        0.22504+0.146459im     -0.0830652+0.017371im      0.0945109+0.0265374im   0.0474912-0.145535im     0.0988165-0.199916im      -0.184845-0.0279563im     -0.307408+0.0346873im      0.109884+0.130005im    0.0850314+0.00308009im   -0.0742087-0.089478im       0.148459+0.0985823im    -0.0362195-0.130083im    -0.0932875-0.23444im      -0.0535747+0.0300316im    -0.0740583-0.0156969im     0.0689604+0.201184im     0.0841216+0.0187605im       0.132694+0.173489im    0.0483907+0.298686im      0.0181689+0.164846im
  -0.102289-0.183534im    0.0734103-0.00191178im    0.0142688-0.00808411im   -0.221967+0.142324im   -0.0759626+0.427049im       -0.132155-0.0522537im      0.12039-0.0389494im     0.0543898-0.126337im    -0.0296292+0.0208543im     -0.191594-0.182074im        0.139773-0.118976im      -0.104653+0.0125184im     0.0903956+0.0984532im      -0.11782-0.212448im       0.124416+0.0603393im    0.205057-0.0780714im    -0.133514-0.0647294im    0.00905392+0.0637358im     0.0747406+0.0939338im   -0.00974774+0.121847im     0.184065+0.060309im      -0.144869-0.0354879im     -0.077606+0.0176307im    -0.0842666+0.0425877im    -0.217222-0.0336521im     -0.176179+0.133963im     -0.0754212+0.0322617im     -0.119084+0.0709108im    -0.105383-0.00362096im    -0.0417558+0.0105073im  -0.0335483-0.246415im       -0.10343-0.194938im
   0.114922+0.0486209im   -0.064544+0.0864548im     -0.191285+0.0901448im     -0.24891+0.134221im    -0.100972+0.122719im      -0.0156666+0.133659im    -0.0589736-0.0282791im     0.0855507+0.18635im      0.0729777+0.0963767im     -0.114305+0.0071731im     -0.0428004-0.270856im     -0.0856674-0.0612001im     0.0321821-0.272598im       0.233722+0.0051738im    -0.0418928+0.200919im    -0.170548+0.125271im      0.202519-0.0819561im     0.0979626+0.0668524im    -0.0307198+0.00601739im    -0.193829-0.028403im   -0.0484162-0.00846344im    -0.105352+0.0985471im    0.00387799+0.0996778im      0.283504+0.00636652im  0.00574408-0.108471im      0.0786939-0.00425143im    0.0450703+0.216808im       0.125775+0.0759381im    0.0577934+0.0523102im      -0.092436-0.0291666im   -0.269145+0.0674025im     0.0508945-0.170525im
  0.0790185-0.0122308im   -0.062564-0.0135728im     0.0280576+0.181694im    -0.0297078+0.09634im    -0.0747906+0.16338im        -0.103422+0.0503563im    -0.373675+0.18847im       0.0403453-0.0980023im  -0.00815193+0.0528159im    -0.0413246+0.0587213im     -0.0189085+0.0108695im     -0.221105-0.101125im      -0.087618+0.112537im     -0.0145343+0.121482im      -0.092083-0.160585im   -0.0223498+0.0351021im     0.127384+0.27497im       -0.141392-0.153168im       0.130231-0.270919im      -0.117799-0.17822im      0.129253+0.223039im     -0.0670127-0.05295im       -0.011981-0.176442im     -0.0554992-0.047521im     -0.204309-0.0426682im     0.0771083+0.191175im       0.075619+0.0763758im   -0.00425119+0.0830726im   -0.0929811+0.124387im       0.0433812-0.0244545im    0.183605+0.119255im      0.0878336+0.0794547im
  0.0430456+0.146787im    -0.022543+0.108983im       0.212573-0.0676534im   -0.0602656+0.106177im    -0.162534-0.158934im      -0.0308579+0.0907785im     0.150824-0.0721012im     -0.243861+0.0359815im     0.204909-0.244451im      0.0361274-0.0458928im      0.0290216+0.0377565im     0.0846467+0.140747im    -0.00218341+0.0726037im     -0.125594-0.0284906im   0.000909375+0.0504224im   -0.125991-0.00134671im   0.0499584+0.0680209im    -0.0899821-0.191261im       0.109744-0.0714817im    -0.0605946+0.0585366im    0.196309+0.115443im     -0.0117392+0.0369398im     0.0636773+0.153269im      -0.123356+0.00843539im   -0.158125+0.0327754im     0.0345294-0.162839im     -0.0961591+0.245155im       0.046522-0.0985705im    -0.308012-0.143284im       -0.109386-0.274036im    -0.109457+0.188808im     -0.0465553-0.125544im
  -0.209717-0.147631im     0.125997-0.0625564im     0.0376749-0.0175046im   -0.0508649-0.117379im     0.105972+0.0678081im      0.0732419+0.117444im     -0.284995-0.0798296im     0.0302821-0.107714im    -0.0409459+0.056085im      0.0968732-0.175717im       -0.220112-0.135302im     -0.0356335-0.0231676im     0.0144075+0.0330755im      0.330554-0.0570515im    -0.0441497+0.0491953im   -0.329902-0.0859207im     0.045389+0.0703774im    -0.0282167-0.140083im      0.0384945-0.072893im        0.23788+0.219244im    0.0249582-0.143548im      -0.110121+0.0913801im     0.0539811+0.19023im       -0.202723+0.0810744im   -0.0187692+0.00491231im    -0.200926-0.0384346im     -0.106112-0.0506409im     0.0714721-0.097677im     0.0067009-0.118403im      -0.0917504-0.028868im     0.134583+0.0260376im      0.173722-0.053358im
  -0.129663-0.100298im    0.0106206-0.0733776im     0.0192362+0.00282135im  -0.0901803-0.135789im     0.146463+0.00865868im      0.163286-0.0918251im  -0.00914544-0.148904im      0.0826087+0.181271im      0.128925-0.149125im      -0.300454+0.0134997im       0.176893-0.179868im      -0.130687-0.106633im     -0.0662253-0.0221891im     -0.134565+0.00744476im    -0.133201+0.161024im    -0.110523-0.06817im      -0.181282-0.22654im       -0.235981+0.12332im      -0.0584069-0.175678im     -0.0529107-0.135006im    -0.143989+0.0825854im      0.188412-0.0849183im     0.0553956+0.0658897im     -0.227504-0.0383753im    -0.110943+0.0767924im      0.218853-0.033132im      0.0112603-0.0675119im      0.130034+0.130148im    -0.0483975-0.131358im       0.0214458+0.0903892im    0.109531+0.110254im       0.125948-0.0433755im
  -0.178881-0.0369838im   0.0773297-0.151511im        0.24111-0.202437im     -0.102803+0.0380535im   0.0398089+0.267063im       0.0698723+0.0434563im    0.0271487-0.0335954im     0.0157595-0.0339981im   -0.0764316-0.0443441im      0.137765-0.0218404im      -0.158929+0.255614im     -0.0919095-0.270773im      -0.173029-0.0334623im    -0.0882315+0.341277im      0.0370633-0.018694im    -0.175853+0.0874591im    0.0742001-0.069143im      -0.146486-0.0485657im    0.00400637+0.195106im      -0.136495-0.0291267im   0.0492671-0.135616im        0.17633-0.0613744im    -0.0617454-0.0548261im     0.0584738-0.0197432im    0.0810809-0.220469im       0.090984-0.0453332im     -0.144797+0.0306825im     0.0628733+0.0657393im   0.00619601+0.0141845im       0.145729-0.0578545im  -0.0831547-0.033831im      -0.183812-0.167472im
  -0.122381-0.0283721im  -0.0840153-0.0796341im    -0.0396581-0.0632968im     0.039755-0.0554457im   0.0226439-0.0956091im     -0.0122841+0.0257328im    -0.155452+0.141471im       0.121945-0.107677im   0.000980453+0.124305im       0.181906+0.0421268im      0.0600621-0.102011im      0.0438872+0.121224im     -0.0839992-0.307634im      -0.207715-0.0413543im    -0.0512266+0.235379im    0.0879496-0.252979im      0.128278-0.0997312im     -0.177999-0.0855466im      0.140935+0.125181im     -0.0693517+0.177823im    -0.154014-9.32427e-6im     0.104405-0.141669im       0.243799-0.0697209im    -0.0227504-0.00171107im  -0.0956778-0.119201im      0.0421727+0.0211423im       0.10146-0.045009im     -0.0225091-0.0851709im    -0.169204+0.261283im       -0.159696-0.243705im   -0.0447817-0.181008im      0.0331181+0.0447574im
  0.0536143-0.0616378im  -0.0305411-0.133033im      0.0256721+0.143849im     -0.130731-0.165956im     0.138291-0.0648598im      -0.140102+0.252624im     -0.207701-0.0645372im     0.0554257+0.121306im     0.0557039-0.0871063im     0.0208896-0.0903126im      0.0509178+0.207477im      0.0488626+0.229903im      -0.272184-0.0984525im     0.0225993-0.0021526im       0.08877+0.0342739im   0.0435439-0.24258im     -0.0679146+0.0710848im     -0.039963+0.282337im       -0.13305+0.111722im     -0.0192063-0.171099im    0.0945243-0.0854465im     -0.110048+0.144305im     -0.0596867+0.102632im      0.0836514-0.0544834im   -0.0736013-0.076964im      0.0852941-0.100472im     -0.0595404+0.215384im      -0.299689-0.00606997im   0.0313682-0.0246985im     -0.0591209+0.0386485im    0.218139+0.00660017im    -0.124897-0.0156558im
   0.113994-0.180314im    0.0364565+0.0612092im    -0.0990881-0.185812im    -0.0589596+0.0880224im   -0.011957+0.134118im       -0.127667+0.12542im     -0.0903434+0.0465768im    -0.0845159+0.0800357im    0.0774299-0.0173508im    -0.0149602-0.032799im      0.00630373+0.125051im      -0.110965+0.175499im     -0.0315832+0.171889im       -0.20963+0.143853im       0.122863+0.278239im   -0.0665585-0.0410988im    0.0859552+0.0240834im      0.157671-0.0568779im     -0.114626-0.0361238im     -0.163025+0.0769898im    -0.35395-0.0244478im     0.0915525-0.035127im      0.0123962-0.0746368im     -0.114334-0.0669336im     0.142098+0.226044im      -0.130922+0.252682im      -0.155381+0.158061im     -0.0301544-0.243278im     0.0982355-0.101836im       0.0616833+0.0389356im    -0.02246+0.0501172im      0.128718+0.106784im
  -0.150583+0.0781495im   0.0647402-0.076069im       0.166675-0.215837im     0.0488526-0.0564713im    -0.16556-0.154802im       -0.102167+0.246613im     -0.131943+0.0463421im    -0.0541869-0.0458229im    0.0413924-0.134859im     0.00817391+0.0604692im       0.109329-0.0170142im     -0.148243-0.0937071im    -0.0709633-0.0343853im      0.177759+0.0434143im     -0.121998-0.116462im      0.24468-0.111007im     -0.104884-0.341897im       0.191256-0.157972im     0.00406236-0.00965943im    -0.115616-0.0406263im   0.0783091+0.112267im      -0.154081+0.0152634im      0.298048-0.0104333im    -0.0605992+0.201077im     0.0464842+0.0631042im   -0.00228338+0.146777im      0.0339571+0.0784384im     0.0335279-0.0277276im     0.216756+0.00502233im    4.90565e-5+0.198812im   -0.0486996+0.0241238im    -0.0782728-0.119567im
  0.0600925+0.0171121im  -0.0684013-0.106267im       0.278889-0.031571im    -0.0884941-0.0917947im   -0.175401+0.201643im       0.0475248+0.171852im     0.0373871-0.131812im       -0.21815+0.0510138im  -0.00275692+0.340576im     -0.0135235-0.00961839im    -0.0308761-0.110465im      0.0829078+0.266157im     -0.0878813-0.049398im      0.0462306-0.0511555im      0.260622-0.09692im     0.0610091+0.180419im     -0.182779-0.020062im       -0.10044-0.0320578im      0.111429-0.05746im      -0.0521781-0.131118im    -0.219781+0.0420583im    -0.0920023+0.0270767im    -0.0363724+0.123955im      -0.155716+0.0616294im     0.181085-0.0120973im     0.0955359-0.0684932im      0.121834-0.00663955im     0.223989+0.00597377im   0.0144524+0.180261im       0.0719665-0.0647754im    0.125984-0.0940554im   -0.00334863+0.118472im
  -0.204092+0.029771im     0.115263-0.193737im     -0.0400359-0.143515im     0.0955076-0.0949065im   -0.194676+0.000559779im   -0.0446047-0.0771819im  -0.00988244+0.122693im     -0.0794653-0.0428556im     0.199917-0.0208085im     -0.181718+0.14623im       -0.0536541+0.0473655im    -0.0940518-0.0806317im      0.102513+0.0968199im      0.110404+0.0906491im      0.216562+0.0426023im    0.154929-0.0137077im    -0.177625+0.145739im     -0.0702348-0.0642502im    -0.0243957+0.120764im       -0.08223+0.0614298im  -0.0869365-0.12481im       0.0423417+0.229777im   -0.000340648+0.113793im       0.215455-0.184389im     -0.140868+0.0866871im   -0.00468991-0.173357im     0.00193099-0.00406019im    -0.150819+0.104643im    -0.0406413+0.215079im      -0.0129771-0.0383683im   -0.027279+0.107474im       0.392953-0.051246im
 -0.0180784-0.226212im    0.0139353-0.0665345im     0.0363913+0.0380992im     0.030861-0.227397im     0.071177+0.0151595im      -0.124765+0.325523im      0.103594+0.103615im      0.0853306+0.263393im     0.0957233-0.175585im       0.100725+0.17273im        0.0153329-0.146683im      -0.114165+0.0226059im    0.00249279+0.129344im    -0.00256006-0.145858im      0.0959661-0.0571563im  -0.0944485+0.241528im      0.020225-0.00586812im     -0.14942-0.0115424im   -0.00680724+0.164334im       0.164354-0.0559564im   0.0870827+0.0829151im    0.00617606-0.187116im       0.122995-0.0444068im      0.207354+0.0514597im    -0.155423+0.0538485im     -0.185955+0.0220962im     -0.134967-0.0718365im     0.0779265+0.0798372im    0.0228319+0.0233793im      0.0856006-0.0956787im   -0.171128-0.0283876im    -0.0308666+0.302622im
  -0.127759-0.119072im    -0.339211-0.0896218im    -0.0429421+0.0735898im   -0.0761292+0.0143898im   0.0636066+0.0817596im      -0.137692-0.0999381im     0.131913-0.0420468im     -0.151251+0.0208528im   -0.0477909+0.195051im       0.133448-0.0340108im      0.0188666+0.00731288im   -0.0222867-0.0806562im     -0.165606-0.0287117im     -0.131658+0.0620232im      -0.31649-0.0920081im   -0.111991+0.199787im     -0.236818+0.0506415im     0.0154473-0.206786im       -0.27372+0.16467im       0.0158091+0.107275im    0.0846153+0.0597828im     -0.064962-0.0795922im      0.139189+0.139561im       0.071708-0.132773im     0.0304596+0.209969im     0.00788036-0.00327564im     0.187046+0.157775im      -0.104752-0.0246264im    0.0123658-0.03629im        -0.196834+0.082389im      0.04002-0.0231735im     0.0983741+0.00640551im
 -0.0430969-0.0555226im   -0.132604+0.318362im     -0.0374256-0.194571im    -0.0706908-0.185234im     0.109767+0.0160572im       0.110975+0.0192922im   0.00835124+0.0318292im      0.055503-0.170426im      0.119409-0.0457939im    -0.0763068+0.0519084im        0.24422+0.220787im       0.110337-0.0152635im    -0.0163874-0.393225im        0.11979-0.0971941im      0.109938+0.0844808im   -0.133937+0.124821im     -0.154979+0.116457im       0.062405-0.103617im     -0.0815166-0.0390276im    -0.0921169+0.0766462im    0.233249+0.0432422im    -0.0108939+0.0162763im    -0.0684563+0.0119771im    -0.0871641-0.0750251im    0.0441108+0.0215563im    -0.0770753+0.170425im      -0.168735-0.0376309im     0.0712365+0.0504526im   -0.0760134+0.282289im        0.124042+0.111021im    0.0422891+0.116955im     -0.0234862+0.0932428im
    0.11784+0.0988804im   -0.271572-0.094515im      -0.055325+0.00996253im  -0.0759632-0.0584247im  -0.0485646+0.0248167im    -0.00513952-0.0569242im    0.0587003-7.44475e-5im     0.233762-0.0310362im       0.1535-0.108662im      -0.109056-0.134778im      -0.0599113+0.0549982im     -0.107913-0.119785im     -0.0282581+0.0336181im     -0.145795+0.0294787im      0.119544-0.0234845im   0.0758093-0.0612467im     0.237221-0.0629509im   -0.00568242-0.174993im       0.197303+0.11483im       0.0280141+0.224848im   -0.0067088+0.01477im       -0.103577+0.0368929im    -0.0567295+0.265003im       0.218383+0.242085im      0.113196+0.192236im       0.189535-0.0242165im     -0.145204-0.0828587im      0.138104+0.0056277im   -0.0312189-0.0213601im     -0.0297889+0.135997im     0.314988-0.00331573im   -0.0480625+0.165702im
   0.166152-0.167919im     0.184128-0.207292im      0.0409032-0.0357779im    -0.252234+0.118479im   0.00716782-0.0366529im     0.00312789+0.0121316im    0.0462823-0.0570603im      0.061894-0.0260148im     0.144499-0.0275154im      0.130149+0.208574im        0.101442+0.146103im      -0.104872+0.0725246im      0.241273+0.0603617im    -0.0619979-0.0661006im     -0.201257+0.107032im    -0.147824+0.184044im     -0.116008+0.080106im        0.19401-0.0137934im      0.223581-0.0231579im      0.136562+0.0857405im   -0.021487-0.0147169im     -0.058271+0.0815136im     0.0769536-0.105844im      -0.115878+0.0263149im    0.0529331-0.134722im       0.319928-0.106679im     -0.0814624-0.086417im      -0.148585+0.0314052im     0.135054+0.203411im       -0.221501+0.0831635im    0.037016+0.00471777im   -0.0379366+0.0324631im
  -0.128361-0.0798471im  -0.0510172-0.0988616im    -0.0541629-0.0104743im    0.0506527-0.146866im   -0.0912387+0.0772146im      -0.110084-0.257341im   0.000280178-0.164221im      0.0894756-0.309091im      0.325982-0.0542943im   -0.00700835+0.159292im       0.0706695-0.110592im       0.235681+0.217194im      0.0622807+0.207659im       0.072246+0.0420172im     -0.101601+0.0611869im   -0.183613+0.0161828im     0.110382-0.0953501im     -0.121291-0.00644176im    0.0761079+0.154934im     -0.0799236-0.215807im    0.0674305-0.0709028im     0.0323906+0.0508695im    -0.0844023-0.0706996im     0.0965825+0.047095im      0.013729-0.0722327im     -0.115398+0.155802im        0.20554+0.143476im       0.104688-0.153347im      0.149538-0.000476637im  -0.00236202+0.0228541im   0.0889518+0.0895451im     -0.151832+0.000947915im
     0.1624-0.0747708im   0.0777609-0.0284522im   -0.00438245+0.119752im    -0.0712935-0.179002im    0.0446144-0.113345im       -0.101763-0.132194im     0.0901016+0.092561im       0.106204+0.100964im     0.0360764+0.0452404im    -0.0464438+0.0766591im      -0.178173+0.168982im       0.152858+0.124607im     -0.0624562-0.106162im    -0.00190794+0.2144im       -0.0505307+0.0287059im    0.112125+0.150459im     -0.195675-0.00466149im    -0.109856-0.0214745im      0.228164-0.224254im      -0.133362+0.286252im    0.0310011-0.210305im    -0.00625875+0.0159464im      0.101058-0.0298857im    -0.0244556+0.20269im     -0.0722562-0.0302312im     -0.174305+0.160632im       0.061565+0.180062im      0.0495604+0.30559im      0.0640285-0.215856im       0.0554729-0.0306119im  -0.0160272-0.0951617im     0.0701595-0.0637355im
 -0.0802679+0.233763im    0.0876821+0.0557437im    -0.0630128+0.0960489im   -0.0153694-0.050095im   -0.0404143-0.000193957im  -0.00339217+0.384665im    -0.0519065+0.00276258im     0.038906-0.120488im     -0.127106+0.115974im      -0.187285+0.199586im        0.185452+0.0789648im     0.0163826-0.0185265im     0.0184801-0.0182078im     -0.280116+0.156323im      -0.173721+0.0292252im   0.0145663+0.159313im    -0.0641097-0.0502775im    -0.0509115+0.0167373im    -0.0503277+0.0733751im      0.076132+0.136936im      -0.0518+0.155834im       0.100288+0.252289im      -0.269171+0.00947676im    0.0459314+0.0905951im   -0.0775417-0.117411im      -0.249797-0.0667788im   -0.00695354-0.111262im       0.140682-0.105695im     0.0978914-0.108457im       -0.203361-0.0625342im    0.117011+0.0280586im     0.0169204-0.0306573im
   0.053086+0.130772im    0.0716689-0.00787813im    0.0943952-0.180107im       0.11799+0.0915248im     0.16331-0.104162im      0.00320351+0.0599474im     0.360459-0.162326im      0.0983417-0.0484042im    -0.102786-0.0962485im    -0.0391678+0.0172187im      -0.151579-0.0519071im   -0.00764448-0.0971136im    -0.0388754+0.0428638im      0.062905-0.0178331im     0.0304424+0.259448im   -0.0894982-0.0615546im   -0.0122696+0.146965im     -0.0275633-0.160058im      -0.103958-0.120606im     -0.0836858-0.139973im    -0.142082+0.20554im       -0.184772+0.0172333im     0.0902786+0.09759im        0.118247-0.121263im     -0.086602-0.169246im     -0.0927064+0.20996im       0.0313614+0.0129673im    -0.0736874+0.144772im      0.184862+0.0597144im      -0.106386-0.14759im       0.30269-0.183448im     -0.0301482+0.0252743im
  -0.110915+0.0153419im   0.0435671+0.0781327im     0.0137547-0.082592im       0.16087-0.0890971im  -0.0641425+0.0918808im     -0.0479931-0.013999im     0.0585951+0.123385im     -0.0208532-0.0996312im     0.148224+0.0276685im     0.0314867-0.0312688im   -0.000484349-0.31469im       0.0202154+0.0484577im    -0.0155783-0.0483291im     0.0163526+0.0855675im    -0.0508724-0.205428im    0.0570248+0.131553im     0.0474417+0.079045im      0.0385902+0.182632im      -0.125573-0.0340578im    -0.0782506+0.134871im    -0.175004-0.0420926im    -0.0394758+0.138521im       0.176926-0.189323im    -0.00286556-0.170533im     0.0961488-0.164008im      0.0946659+0.0210616im     -0.360926+0.0884169im     0.0130308+0.163032im     -0.230112-0.196226im       -0.255731+0.117701im     0.168036+0.0121982im     -0.188351+0.116767im
   0.102111+0.106267im   -0.0997817+0.100031im       0.120306-0.173386im    -0.0411289+0.0600461im  -0.0637942+0.00400225im     0.0658782+0.115154im      -0.11478-0.188136im     0.00420877-0.197579im      0.291821-0.0108728im    -0.0598822+0.112144im       -0.113589-0.0290664im     -0.228894+0.00293344im   -0.0128102-0.110168im     -0.0296344-0.115273im      0.0589316-0.0929821im   0.0155123-0.00908483im   0.0256289-0.0735491im      0.071176+0.0207049im     -0.162485-0.0188096im      0.156144+0.0483763im   0.0443293-0.163933im       0.139649-0.329942im      -0.195559-0.138016im     0.00862773+0.096905im      0.136192-0.0359764im    -0.0702837-0.0198315im      0.194415+0.0734285im     -0.238323+0.268793im     0.0249935-0.165058im       -0.130656-0.162812im    0.0536091-0.0297409im      0.154143+0.0854462im
 0.00466599-0.0265229im   0.0202422-0.0654008im     -0.180176+0.0677085im    -0.107788+0.177755im     0.114626+0.0330969im     -0.0334428+0.0329357im   -0.0561489+0.0311931im    -0.0448524+0.0176289im  -0.00318818+0.0770662im    -0.0869604+0.249206im      -0.0372773+0.0806109im      0.273189-0.164147im      -0.122059+0.0950931im      0.245989-0.0841938im    -0.0170839+0.118281im     0.154256-0.0821642im    -0.033834-0.175668im      -0.120767-0.235278im      0.0593484+0.032605im     -0.0794667-0.206168im    0.0636149-0.0292281im    -0.0206878-0.0510184im    -0.0945622-0.174902im     -0.0895344-0.0591696im     0.216748+0.25321im      -0.0516369-0.14771im       -0.291917+0.00974112im    0.0500814+0.124773im    -0.0814005-0.049456im       -0.263667-0.144124im    0.0299554-0.086494im     -0.0525862+0.078644im
  0.0342388+0.0946516im   -0.149546-0.156316im        0.28199+0.056312im      0.173552-0.0841929im   0.0945934+0.0723482im      0.0815815-0.0411101im   -0.0732246-0.0737866im     -0.132569+0.19172im     -0.0874428+0.00545719im    -0.263194+0.175746im        0.186203+0.00385082im     0.156251-0.0295071im    -0.0323019+0.00137414im   -0.0279797-0.087582im      0.0745355+0.070462im   -0.0583269+0.0134081im     0.125807+0.0331743im      0.160324-0.0731258im     0.0795346+0.0320312im     0.0334414+0.169232im    0.0579762-0.185833im      -0.239393-0.23985im       0.0165018-0.289422im       0.131059-0.13034im     -0.0998827-0.143362im      0.0431267+0.00819072im    -0.100034+0.0577611im     0.0751855-0.200095im      0.039304-0.0780696im     -0.0135771+0.113874im    0.0865128-0.0473895im       0.19811-0.163762im
   0.283662-0.0305067im   -0.107235-0.232108im    -0.00552341-0.0713544im    -0.115337-0.0725776im    0.147219+0.0279008im       -0.10197+0.0468809im     0.221263+0.237175im      0.0651499-0.229665im    -0.0917135-0.142365im      -0.220369-0.0108902im      0.0156617-0.100582im     -0.0532358-0.0754504im    -0.0372367-0.123647im      0.0363585+0.111828im       0.124434-0.0302195im   0.0581922-0.00208975im   0.0565173+0.133425im     -0.0541427-0.0537258im    -0.0739799+0.0967278im    -0.0122599-0.18272im     0.0540925-0.141731im     -0.0802541+0.0677317im     0.0985814+0.0129204im     -0.305612+0.0356683im     0.095341-0.189321im     -0.0578479-0.0623823im      0.176233-0.116433im     0.00734688-0.199347im     -0.059987-0.16446im        -0.143863+0.057536im     -0.21396+0.114537im       0.103596+0.105423im
  -0.136088-0.0995122im  -0.0504478+0.111737im     -0.0447492+0.152036im      -0.14764+0.0678676im   -0.192917-0.24383im        0.0668863+0.0720542im     0.027785+0.0388328im     0.0409271+0.162084im     0.0889279-0.0653375im     -0.221375-0.0805432im      -0.162886-0.00799854im   -0.0629124+0.0860575im       0.21042-0.0695327im     0.0709907+0.134862im      0.0248748-0.205564im    0.0121279-0.0666317im      -0.1222+0.102262im     -0.0896115-0.267647im      -0.114407+0.00416409im   -0.0756318-0.0167371im  -0.0781241-0.232396im      0.0944309-0.223946im       -0.13333-0.00861215im   -0.0607016-0.129835im     -0.162262-0.0954211im     0.0329314+0.0424996im    -0.0454456-0.0519301im     0.0527208-0.234485im      0.141026+0.0828946im      -0.154488+0.0857498im   0.0413725-0.192135im      -0.252401+0.0116301im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
    0.0045663398657191 + 0.3196465541535323im
   0.04361940008302161 - 0.11328229997399565im
   0.02334380188005483 - 0.1324825512588765im
  -0.03911727172906929 - 0.12682225440784253im
  0.025054818783270233 + 0.19871005290344262im
  -0.20797746589895852 - 0.03172994143782215im
    0.1018618468998954 - 0.09089800309371307im
   0.07411171949360944 + 0.01767112157278636im
 0.0013787225513027914 - 0.08963493752427922im
  0.016778864413069767 - 0.09601074097587163im
   0.13437614646821464 - 0.16379563689459928im
  0.008769761507329313 + 0.0924698779947235im
  -0.20845673560000968 + 0.21288193452109316im
  -0.05934241013102007 + 0.07943458806114591im
   0.44515334282377306 + 0.0im
   0.12012137274936785 + 0.049225302718559im
   0.04804892378560364 - 0.0004404058244317813im
   0.13684725795297276 - 0.022804628441209538im
   0.02544517298764922 + 0.034455456566757525im
  -0.02557959517494403 + 0.09840005477211955im
  -0.06537139694047445 - 0.026250585737654847im
  -0.09715281743110978 - 0.08825125723985923im
   0.03180440748123697 - 0.22437407635567172im
    -0.170218885824727 + 0.09816558397118898im
 -0.017448831934857603 - 0.0671504624517419im
  -0.15251239306474346 + 0.0317718991169775im
    0.1367935989018975 - 0.035270459249532524im
  -0.06737888375445952 - 0.03819850727697194im
  -0.19388872434369991 + 0.1256565490239239im
  -0.17699962088525048 - 0.11811776759438965im
  -0.05778581969907917 + 0.2252361003128943im
 -0.008592689217136868 + 0.012009556260218813im

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.