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.10563-0.0145919im    -0.0584726+0.0282228im     -0.308874-0.00923785im    -0.257382-0.0325702im  0.00690808+0.0361959im      0.240933-0.0405658im      0.150937+0.129814im       0.216537-0.182087im      -0.156466+0.225346im       0.0797138-0.104628im      -0.111273-0.0807728im    0.0103032+0.00863329im   -0.163435+0.102972im        0.155045-0.0109696im    -0.0829222-0.0386414im    -0.140263-0.160511im      -0.065626-0.0298908im     0.114642-0.0717724im    -0.00512717-0.123938im     0.0173448-0.117353im     -0.0112743-0.212386im      0.0264941-0.0809498im      0.0284975+0.279585im    -0.00433613-0.0132393im      0.0163456+0.0137865im     0.00493969-0.0494337im   -0.00415632+0.104281im      0.287603+0.0117356im     -0.165394-0.0766036im     0.0750385+0.0437406im    -0.193635-0.21105im       0.0815512+0.0567151im
  -0.0213755-0.135294im     -0.0106031-0.0672876im     -0.129385+0.0227693im       0.10861-0.0335426im   0.0323284-0.108572im      0.0254071+0.0521909im    -0.0230125-0.0759844im     0.0377423+0.037742im      0.0151671-0.121488im        0.165307+0.0809496im     -0.050197+0.0282615im     0.178744+0.253502im    -0.0947129+0.14446im        -0.108067-0.289123im      -0.186807+0.171592im     0.0932055-0.249821im      0.0506423+0.0147657im   -0.0295339-0.207776im       -0.116077-0.112176im      0.186954+0.0231988im      0.082774+0.281841im     -0.0928379+0.0189508im      0.0947852-0.0830925im     -0.207746+0.0467739im      0.0494295-0.185303im        0.123955-0.042793im       0.225217+0.0166187im    -0.134296-0.0118329im     -0.155726-0.242718im       0.140459+0.0215668im   -0.0122268+0.0401101im     0.0356152+0.133079im
   -0.201635-0.00483134im    0.0173496-0.0170829im     0.0653569+0.0835788im      0.142977-0.0840491im    -0.26872-0.316837im     -0.0955957+0.0435452im    -0.0811502+0.142619im     -0.0337298-0.0693485im     -0.202204-0.0258864im     -0.0306236-0.189291im         0.1124+0.113614im    -0.0632748+0.0737205im    -0.180122+0.11461im         0.074862+0.0666657im     -0.035267+0.159701im      0.021349+0.0566996im     -0.163466-0.193908im    -0.0363627+0.000972158im    0.0804015-0.260108im     0.0265448+0.0493948im     -0.168613+0.0593396im      0.103258+0.0235332im       0.193211+0.0657123im      0.165573+0.135532im        0.203558+0.0916484im      -0.125632-0.218222im     -0.0623206-0.0137804im     -0.14309+0.0218131im      0.106308+0.0588548im      0.180515+0.102532im      0.037949-0.0380259im    -0.0920257-0.152042im
   -0.274308-0.0391585im     -0.230784+0.0576546im    -0.0416471+0.0342127im   -0.00483481-0.12921im    -0.0411097+0.0719377im      0.163407+0.130376im        0.17376-0.0622857im    -0.0434787+0.0814045im     0.0258752+0.116025im       -0.180636-0.0737912im      0.105824+0.0866662im    -0.129038-0.00821612im   0.0807953-0.0324104im      0.0606614-0.156821im       -0.21618+0.0809799im  -0.00160292+0.0511928im      0.131817-0.122133im     -0.156582+0.0940759im        0.27485+0.0861108im    -0.102181-0.145961im      -0.134891+0.10998im        0.193249-0.143342im       -0.287307-0.167715im     -0.0660611+0.0524836im       0.022744-0.13195im        0.0105125-0.0853537im     0.0213012-0.0275444im   -0.0133973-0.185801im      -0.184351-0.0108482im     -0.155304+0.129199im     0.0308295+0.024396im      -0.200442+0.101216im
   0.0228838+0.144103im     -0.0345378+0.0904594im     -0.201999-0.0353502im    -0.0322547-0.0480496im    -0.11839-0.102128im       0.151974+0.154853im     -0.0219871-0.175816im       -0.11337-0.210259im       -0.12076-0.100811im        0.100908-0.00451641im   -0.0454753+0.228974im    -0.0918649-0.0136607im    0.0984551-0.0277506im      -0.203221+0.0978831im      0.259162+0.0150715im   0.00671589+0.108701im       0.119441-0.153012im      0.105447-0.212375im       -0.118614+0.147577im      0.123339+0.183718im      -0.249898+0.00106424im    0.0142479-0.00127372im     -0.190965-0.0296718im     0.0393491-0.113131im      -0.0199926-0.217416im        0.158579-0.0959289im    -0.0479199+0.130474im      0.159184+0.0333075im      0.190847+0.0521653im      0.160365+0.0491787im    -0.027623+0.0743218im    -0.0268765+0.173626im
    0.320099-0.132771im       0.111251-0.0865978im     0.0260521-0.0567431im      0.164478+0.0652813im    0.161422-0.0783067im     0.0158942+0.010043im       0.185609+0.0778373im     0.0780039-0.0787242im     0.0340048+0.143101im      -0.0746518+0.0947459im     0.0715526+0.183021im      0.198296+0.0183925im    -0.117751+0.0404201im      -0.105832-0.0534492im      0.254822-0.0529356im     0.164101+0.0873882im     0.0922963+0.0405183im      0.02993+0.193851im        0.101833-0.0657125im     0.100935-0.171106im     -0.0335008+0.00593383im     0.240402-0.139161im       -0.137173-0.0370991im    -0.0270328-0.0542053im     -0.0681339-0.0106084im      -0.147685-0.0746449im      0.208825-0.0969675im     0.112805+0.057169im     -0.0854784+0.100008im       0.295303+0.18456im      -0.129312+0.0306558im    -0.0614151-0.164476im
    0.208295+0.0390094im    -0.0959918+0.223585im    -0.00926431+0.0169675im      0.139419-0.0646647im   0.0252759+0.0574421im     0.0997653+0.0911331im    -0.0807186-0.10184im       0.0951447+0.0410572im     -0.124215-0.0608343im     -0.0020896-0.0457934im    -0.0160213-0.181143im      0.142602+0.15225im      -0.288158+0.0390991im      0.0186131-0.0653556im    -0.0524464-0.181104im      0.109691+0.0992743im    -0.0971998-0.00947915im   -0.129578-0.0316004im      -0.117371+0.195476im     -0.128745+0.0215993im     -0.144097+0.123302im      0.0589281+0.00665877im      0.181848-0.0473178im      0.172071+0.209116im      -0.0416274-0.106115im        0.112264+0.204342im      -0.270289-0.213199im        0.2134-0.117361im      -0.176151+0.172295im      0.0801162+0.0818889im     0.114832-0.0304631im   -0.00483451-3.34782e-5im
    0.151253+0.131108im       0.252915+0.133358im       0.268648+0.142833im     -0.0114287-0.0393489im   0.0561195+0.0360607im     0.0907447+0.037404im       0.302319-0.0947208im     0.0925439+0.117863im      0.0175514-0.156035im        0.135001-0.153747im      -0.183519+0.181543im      0.120769-0.0156021im    -0.163657+0.00793652im     0.0471625-0.0643515im    -0.0204985-0.0512157im    -0.263655-0.146732im     -0.0530531-0.0481987im   -0.0441554-0.103189im      -0.0297548-0.0766541im   -0.0881674-0.0603977im    -0.0506118-0.036683im       0.219895-0.234021im      -0.0772954-0.0132828im     -0.141524+0.103537im     -0.00872587+0.0244677im     0.00269879-0.0584655im     -0.124676-0.0395614im   -0.0607989+0.0691807im      0.309034-0.155888im     -0.0950702-0.14015im      0.0526848+0.0237253im    -0.0902169+0.047338im
   0.0222221+0.0800496im     -0.105438+0.116607im     -0.0449521+0.0257532im      0.112107-0.0586082im   0.0252222+0.094115im      0.0174881-0.133152im       0.328413+0.0800758im     0.0715629+0.0413914im     -0.223157+0.115513im       0.0867513-0.167931im      0.0810906+0.0433624im   0.00622313-0.0720184im     0.101655-0.0633416im      -0.222095+0.0702808im   -0.00203768-0.186034im      0.206777+0.0256216im     0.0159444+0.0153537im    0.0333452+0.107836im        0.134771-0.19417im      0.0284623+0.0627927im     0.0193376-0.0480212im     -0.144323+0.097207im        0.116343-0.08859im        0.233659+0.199487im       0.0037047+0.048161im          0.2556+0.0962369im     0.0816091-0.0739502im    -0.149442-0.00517789im    0.0888457-0.216188im     -0.0636452+0.0350552im    -0.252109+0.248513im      0.0579033+0.138929im
   -0.109268+0.000917865im    0.290563+0.0730733im     0.0880117-0.123601im      0.0329231-0.0546321im   0.0258938-0.0152019im    -0.0144197+0.120198im     -0.0588997-0.0470804im    -0.0110375-0.0633753im    -0.0742258+0.287933im       0.0802333+0.107812im    -0.00584797-0.1919im       0.0486657-0.0722738im   -0.0298948-0.0383584im      -0.117314-0.170035im      -0.134336-0.023307im    -0.0306363+0.194322im     0.00902503-0.138432im      0.156992-0.103729im        0.172893+0.0312547im     0.145937-0.0204576im     -0.278125-0.140785im     -0.0530337+0.168333im        0.065736-0.204869im      -0.166645+0.0236554im      -0.196047+0.0129271im      -0.296893+0.00430513im    -0.100061-0.199126im     -0.125405+0.0708893im   0.000140475-0.0518976im     0.0207277-0.106037im    -0.0929434-0.103356im       0.120793+0.192155im
  -0.0626721+0.136824im        0.28761-0.102513im      -0.266285+0.320123im     -0.0720797-0.106215im   0.00416459+0.0170799im     -0.132397-0.0013247im    -0.0664728-0.0440967im     -0.231478+0.0111774im     -0.176087+0.000546386im   -0.0786315+0.141067im         0.1226+0.0292389im    0.0954026+0.0949759im    -0.177663+0.152808im      -0.0253865+0.139713im      -0.101667-0.0113004im     0.133762-0.0416532im      0.159956-0.0303533im   -0.0367775+0.153691im      -0.0241849+0.187849im    -0.0102718-0.00249594im    0.0640525-0.180729im     0.00124074-0.226067im       0.0496998-0.00480138im    -0.166189+0.00875307im       0.12597-0.00489494im     0.0032966+0.143006im      -0.123519+0.0196778im    -0.065822+0.241131im     -0.0342963+0.0343741im     -0.175668+0.149546im      -0.14978+0.139092im     -0.0433071+0.0290484im
  -0.0547786-0.0297124im     0.0424547+0.0248473im      0.248577-0.0342044im    -0.0323617-0.2022im      0.0065185+0.0771929im     0.0885713-0.110397im      -0.191984+0.0479981im     -0.239394+0.0860564im    -0.0104515+0.0439363im       0.105343+0.056679im     -0.0578406-0.0238349im   -0.0283144-0.059549im    -0.0517747+0.0571328im     -0.0319278+0.234108im       0.100679+0.0857962im   -0.0878857-0.0915543im     0.0452258+0.205443im      0.241406-0.0185482im     -0.0586439-0.00931492im  -0.0164369+0.207996im     -0.0990044+0.14104im        0.158049-0.101771im      -0.0128093+0.00750012im  -0.00714082+0.000916599im     0.136586-0.0137993im      0.0823335-0.0786097im      0.145291-0.387083im     0.0952985-0.21788im      -0.0767639-0.113647im      -0.144805+0.181874im     -0.259812-0.147701im      0.0444578-0.0149738im
  -0.0887254+0.0196502im       0.22102+0.0352295im     0.0291571-0.072726im     -0.0287263-0.0627046im   -0.163794+0.0909187im   -0.00620149-0.0291621im     0.0935871+0.0553331im    -0.0375722-0.158233im       0.245107-0.292314im       -0.176316-0.158717im     -0.0442191-0.0792555im     0.228423-0.0516756im    0.0461752-0.0464734im       0.111902+0.0639678im     -0.150291-0.0339693im     0.154027-0.0449392im      0.110395+0.0511456im      0.24502-0.119192im        0.113803+0.184245im      0.120535+0.0790421im      0.012394-0.0641688im     0.0879638+0.0279532im    -0.00876675+0.127253im       0.216151+0.36605im       -0.0778157-0.164721im       -0.186195+0.0351093im      0.229475+0.133259im     0.0313458-0.0108101im    -0.0323314+0.00552769im   0.00370255+0.0770829im    0.0577026+0.0588897im     0.0156985+0.00701314im
   0.0929001-0.122801im      0.0773464-0.120109im      0.0690367-0.0675083im      -0.16777-0.0368592im  -0.0401456-0.114851im    -0.00286212+0.204793im       0.133753-0.0134251im      0.169618-0.0334222im    -0.0482532-0.12416im         0.197885-0.159726im       0.160151-0.109651im     0.0139184+0.321181im     -0.030097-0.0608863im     0.00910261+0.201795im     -0.0198524+0.211402im     -0.121259-0.0941069im    0.00374308+0.109651im     -0.167031+0.152741im        0.101921+0.0969062im   -0.0425468+0.0892137im      -0.13696-0.00885465im    0.0277989+0.0633888im     0.00613371+0.0421378im     0.0916586-0.245083im      -0.0154047+0.0282619im      -0.176983+0.171996im       0.124128-0.00755089im   -0.025091-0.181375im    -0.00561295+0.174137im      -0.067857-0.0861203im    -0.153378+0.234359im      0.0838905+0.222096im
   0.0562227+0.0665741im    -0.0909998-0.106377im    -0.00883627+0.109225im     0.00180383-0.216511im     0.176171-0.166955im       0.192278-0.248406im    -0.00237855-0.0595627im      0.106058+0.0789703im     0.0267264+0.226106im      -0.0515376-0.169373im    -0.00842177-0.0505035im   -0.0326236+0.0424477im    0.0150937+0.0836193im      -0.133176-0.0754065im    -0.0188539-0.0402473im    0.0269688+0.0632563im   0.000474946-0.0164769im   -0.0788036-0.326982im        0.141027+0.0893863im    0.0507965+0.314052im       0.234505-0.120324im      0.0768248+0.0781646im    -0.00856825+0.0204917im    -0.0124763-0.113601im         0.20217+0.00161299im      -0.22116+0.185183im       0.163636-0.111105im     0.0502489+0.0670993im       0.14893+0.0896337im    -0.0389191+0.0689811im     0.208763+0.00560346im    -0.145943-0.0114397im
    0.051821-0.0808996im     0.0994016-0.127821im       0.110403-0.0792719im      0.127122+0.0161051im  -0.0332501+0.228083im      0.0983181+0.0526778im     -0.127732-0.114654im       -0.03799-0.0825426im    0.00388073+0.0426836im      -0.201652-0.151397im      0.0758071-0.0832195im    -0.109393-0.0491347im    0.0298859-0.0521463im     -0.0853844+0.0201412im     0.0737811-0.145116im     -0.100642-0.295524im      0.0921525+0.12747im      -0.162998-0.154311im     -0.00329656-0.06658im      -0.118713-0.198882im      0.0162588-0.0215248im     0.0328081+0.237687im       0.0993063+0.0631428im     -0.177104+0.0977578im       0.116278+0.0256022im       0.054799-0.0314783im     -0.068236+0.109107im      -0.13534+0.0311325im        0.1257+0.217656im       0.163561+0.320469im     -0.162314-0.0571737im    -0.0874436+0.261606im
  -0.0818132-0.109365im       0.109555+0.00204599im   0.00841423+0.0350108im     -0.120248+0.132369im     0.230958+0.00611588im    0.0953285+0.00513709im   -0.0407665+0.0186602im   -0.00334317-0.233124im     -0.0362501+0.0663754im       0.176125+0.140978im       0.417855+0.153808im     0.0554098-0.0513048im    0.0129068-0.146408im        0.209243+0.0832186im     0.0758414+0.0247833im   -0.0111115-0.0563955im     -0.203723-0.0170733im   0.00736819-0.163818im      0.00533576-0.139448im     -0.137855+0.136023im      0.0957532-0.0662974im      0.188531+0.0876715im     -0.0108173-0.199466im      0.0163791+0.12992im       -0.0547875-0.325424im       0.0838919+0.224127im     -0.0617317+0.0735945im    -0.156309-0.0520675im    -0.0433568-0.0130726im    -0.0296424-0.00114569im  0.00269863-0.0687989im    -0.0682845-0.142319im
   0.0331278+0.044775im      0.0505379-0.00891365im     0.043119+0.0553419im      0.110927-0.274343im    -0.165502-0.091952im        0.25966-0.0486345im     -0.144526-0.030969im      0.0283642-0.0530491im    0.00702513-0.110107im        0.117546-0.019347im      0.0128758+0.0958523im    0.0414083+0.102285im      0.348105-0.171155im        0.288832-0.198169im     -0.0743575+0.0634473im     0.230445+0.0437937im     0.0860805+0.155418im    -0.0856652-0.0259224im     -0.0590059-0.103406im     -0.193824-0.0733267im     0.0494429-0.245278im     -0.0322496-0.115087im       0.0729234-0.117385im     -0.0328737-0.117481im        -0.13556+0.104973im       -0.037128-0.0475086im     -0.100078-0.0840353im     0.106468+0.0136653im     0.0639682-0.0733308im      0.083018+0.165377im    -0.0625011+0.0663684im      0.239076-0.0816042im
  -0.0948483+0.12117im       0.0255729+0.165724im     -0.0172249-0.209608im     -0.0426882-0.0996173im   0.0341608-0.247613im      -0.211385+0.207561im       0.170706-0.0833228im     -0.166995+0.00319264im   -0.0911947+0.143715im      -0.0768589+0.0509139im    -0.0354319-0.0218236im      0.15589-0.0876722im      0.15522-0.0625419im     -0.0395984-0.00792181im   -0.0801334-0.0498778im    -0.128881-0.180244im      -0.114129-0.0407191im    -0.165126+0.0386008im     0.00453923+0.0530665im    -0.108286+0.143636im       0.118331+0.22262im       -0.029302+0.103925im       0.0737476+0.160131im      -0.147826-0.0119454im       -0.23437+0.0248188im      -0.066916+0.112914im      0.0119684+0.0488845im     0.212745-0.0325247im      0.131584-0.115633im      0.0132119+0.282378im    -0.0961118+0.0626554im    -0.0211699-0.257689im
   -0.137512-0.0262947im     -0.153964-0.255479im      0.0534419+0.0667115im     0.0231567-0.277269im   -0.0656763+0.117456im      0.0419174-0.0453006im      0.134791-0.0416456im     -0.033097-0.109321im       0.200923+0.0267882im       0.178256+0.278935im      -0.101437+0.145575im      0.164829+0.125025im    -0.0390391-0.0607347im      -0.117863-0.0220003im      0.167851-0.252291im     -0.139551+0.00473621im    -0.101254+0.0663935im    -0.055681+0.043438im         0.11964+0.0447117im    0.0689993+0.0778376im     -0.129115-0.0250657im     0.0600388+0.0375147im       0.245258+0.161878im       0.124997-0.10119im        -0.140026+0.0294549im     -0.0227208-0.124938im      -0.166107+0.128256im     -0.193092+0.0279436im     -0.171681-0.0375896im      -0.12174+0.150821im      0.157274+0.0120083im    -0.0482659+0.01715im
  0.00817288+0.160956im     -0.0617901-0.0362025im     0.0779574-0.133274im       0.202361-0.0833912im    0.092475-0.0927189im     0.0705646-0.0999548im    -0.0120444+0.118069im      0.0481625+0.0171484im      0.116923-0.0618935im      -0.160418-0.0687604im       0.22376-0.0104678im   -0.0103522-0.189287im     -0.183338-0.117926im         -0.0839+0.0185642im      0.068188+0.26803im       0.054482-0.0545791im     0.0368623-0.0990805im     0.145288-0.00705447im      0.111564+0.00626372im   0.0534765-0.0349227im      0.112824+0.0245736im       0.12485-0.067745im        0.417232-0.00550899im    -0.185216-0.145084im       -0.120068-0.105192im       0.0858927-0.0956463im     -0.173752+0.155566im      0.264555-0.0357509im    -0.0479624+0.000270139im   -0.159926-0.157423im    -0.0529804+0.14727im      0.00270076+0.142173im
   0.0552547-0.124994im     -0.0955293+0.0385964im     -0.118984+0.171387im      0.0645398+0.137192im    0.0911061+0.0676262im     -0.117386+0.299058im     -0.0720902+0.0776313im     -0.228479-0.04048im        0.249827-0.0371945im      0.0124556-0.235356im      0.0999385+0.00866205im   0.0453673-0.0253257im   -0.0396574-0.010537im       -0.117461-0.216049im       0.122197-0.0657959im    -0.082876-0.122363im     -0.0400968-0.14827im      0.0440229+0.0479518im      0.0606089-0.0401042im    0.0416326+0.122671im       0.200298-0.0923518im    0.00115256-0.12281im       -0.0382092-0.100989im       0.224124-0.086193im         0.13965+0.0582988im      -0.204424+0.0176012im     -0.198915-0.0364262im    0.0756669-0.13344im       0.0520136-0.19815im      -0.0233553+0.153692im    -0.0202298-0.0997877im      0.280945+0.14095im
    0.014457+0.0973139im      0.113684-0.172318im       0.101185+0.0199252im    -0.0933035-0.0659065im   0.0410374-0.107063im      -0.114741+0.163878im      0.0418221+0.168451im      -0.190614-0.118898im      -0.120082-0.00660249im     -0.204585-0.177973im      -0.185082+0.213416im     -0.123134+0.1932im       0.0453461-0.103798im    -0.000309901-0.0460783im    -0.0166823-0.245665im     0.0165823+0.00684476im    -0.093671+0.123713im      0.105195+0.0154149im       0.142688-0.194735im     -0.111426+0.210026im       0.124402+0.0340454im     -0.065332-0.0526746im     -0.0215692-0.0630878im      -0.17274+0.0469684im     -0.0855944-0.0309642im       0.152733+0.00352136im    0.0215763-0.0929856im    0.0960524+0.0415907im     -0.294002+0.198694im      0.0773846-0.215868im      0.121466-0.0556577im     0.0561804+0.180288im
   -0.185213+0.0609288im      0.065121-0.27096im       -0.263967+0.0846158im     0.0215785+0.026998im     0.107004+0.0513212im    -0.0300832-0.04423im      -0.0619101+0.00613162im      0.36819+0.111987im       0.057466-0.0839233im      -0.130119-0.137393im       0.042212+0.0713813im   -0.0229848-0.0125539im     0.106903-0.164463im      -0.0811296+0.0159783im    -0.0865622-0.105753im    -0.0359501-0.126494im      -0.369977+0.0286487im     0.136563+0.148547im       -0.165075+0.142475im      0.122563+0.0391028im     -0.173045+0.0922465im    -0.0420597-0.136574im       0.0526758-0.204802im     -0.0533166-0.00332294im     -0.127316-0.0427329im    -0.00344885-0.0886567im     0.0629849-0.185594im     0.0178222-0.0446105im       0.21338+0.108089im      -0.005219+0.139588im    -0.0289574-0.0848073im   0.000605308-0.0449364im
   -0.168891-0.0254695im     0.0211614+0.141656im       0.179603-0.148479im    -0.00744988+0.375569im    -0.167529+0.0753094im      0.166201-0.104438im     -0.0022985+0.236347im      0.0395201-0.116116im    -0.00818915-0.01815im      -0.00637245+0.13013im        0.104015+0.169636im     -0.177696+0.177193im     0.0163385+0.257257im       -0.188071+0.0101773im     -0.149689-0.0576128im   -0.0088356-0.175854im      -0.029615-0.0410961im    0.0618498-0.0421602im     -0.0434509+0.14617im     -0.0218512+0.0624825im     0.0305632-0.0575222im      0.121307-0.0542263im      0.0288796-0.0844104im    -0.0167021-0.0767747im      -0.151705+0.261955im      0.00946715+0.116076im     -0.0180533-0.110232im     0.0974499+0.104927im     -0.0281872-0.0731354im     0.0444615+0.171371im      0.203482+0.202529im     0.00644966+0.0562512im
    0.133086+0.226193im     -0.0418265-0.208291im       0.122228+0.022811im       0.219444+0.174785im    -0.246351-0.103288im      0.0458466-0.0749566im     0.0256197-0.0483931im     0.0961928-0.134769im     -0.0683896+0.131278im        0.132407-0.0119966im     -0.170451-0.0681717im   -0.0905015-0.0208048im    -0.016168-0.159813im      -0.0447343+0.173671im      -0.187044-0.147744im    -0.0305942-0.126277im       0.279752-0.290704im     0.0253322+0.103745im       -0.117633+0.0020062im   -0.0599773+0.0496209im      0.141013+0.0861018im     0.0268039-0.154682im       0.0238939-0.113566im      0.0451505-0.0798454im     -0.0474461-0.192804im       -0.137103+0.115414im      0.0302469+0.0966574im    -0.150059-0.137801im     -0.0968178+0.00525227im   -0.0380953+0.0415298im   -0.0516296-0.229091im      0.0569869-0.0811318im
   -0.104043+0.0960687im     -0.183949-0.0517685im      0.164162-0.122905im     -0.0580376+0.0734987im    0.111895+0.0228308im     -0.163818+0.0482383im     -0.259597-0.331035im      0.0154747+0.0252952im     -0.211612+0.0635831im     -0.0151972-0.046009im      -0.088173-0.0761144im    0.0905281+0.290507im      0.162051-0.0109099im      -0.123025-0.0655992im      0.048671-0.0555817im     0.120161-0.0830754im     -0.141277-0.0247819im      0.17366-0.0861886im      0.0714991+0.0480374im     0.101024-0.134244im       0.082218-0.203669im       0.313456-0.192074im    -0.000859044+0.0203601im     0.0515448+0.099157im       0.0316098+0.107682im      0.00831806-0.0269393im    -0.0207944+0.175161im    -0.0326457-0.154457im     -0.0171539-0.0288295im     0.0148193-0.148373im     -0.165429+0.124434im     -0.0568908-0.116743im
    0.284843-0.0591834im     0.0205618-0.0270339im     -0.176236-0.0299624im     -0.139422+0.133095im    -0.110051-0.124854im       0.172581-0.1709im       -0.0516196-0.00105802im    -0.135107+0.0158828im     0.0353318-0.229373im      -0.0761085+0.00426711im    0.0347885-0.205357im      0.118532+0.22312im       0.199843+0.0141902im      -0.113365-0.0187228im    -0.0761065-0.105249im     -0.208672-0.0133261im    -0.0437014-0.125193im      0.137872+0.0134655im       0.233986-0.131214im     -0.126546-0.0433217im    -0.0121312+0.0724908im   -0.00955318+0.145482im       0.0264763-0.146272im      0.0767407-0.0642661im     0.00229254-0.0840727im    -0.00703777-0.186395im      -0.129313-0.110043im     0.0716849+0.189955im      -0.034248-0.0646968im     -0.155857-0.0100016im    -0.177321-0.00775605im    -0.286325-0.12594im
   -0.141638-0.0703557im    -0.0707425-0.0342554im   -0.00982989-0.0607415im    -0.0149943+0.136359im     0.262623-0.089559im       0.201992-0.0555003im      0.109499-0.0865396im     -0.260074+0.113156im      0.0117475+0.0456285im     -0.0508529-0.161062im      -0.239216+0.0698149im    0.0311051+0.193666im     -0.100409-0.0320599im      0.0501769+0.294193im       0.142997+0.204844im      0.214233-0.102863im      0.0401842+0.0503389im   -0.0171373+0.0977315im     -0.0771768+0.0510435im   -0.0744693-0.0690003im     -0.032814-0.135926im      -0.233523+0.0570575im       0.105363-0.154951im      0.0422004+0.0766542im      -0.204947+0.000168329im    -0.193869-0.0171556im    -0.0965917+0.0090913im    -0.024157-0.0292696im     0.0407902-0.170873im      0.0908692+0.0267328im    0.0976727-0.163824im      -0.222365+0.0752639im
 -0.00297866-0.148896im       0.011356-0.0526533im     0.0620372+0.0713329im     -0.222674+0.0173827im   -0.099198-0.133553im     -0.0757183+0.0788514im      0.203374+0.0870285im     0.0461859+0.118942im      0.0813118+0.0763153im      -0.129621-0.0105495im     0.0815137-0.105255im      0.152658+0.0539508im    0.0366223-0.168048im       -0.103866+0.0725725im     0.0554428+0.0740462im    0.0948788+0.220257im    -0.00925113-0.160906im     0.0922402-0.299808im      -0.0885773+0.266547im     -0.319633-0.0776111im     0.0531282+0.0604478im     0.0941753-0.133717im        0.137929-0.0155864im     0.0274828-0.0879514im     0.00980291+0.191756im        0.270134-0.0383073im     0.0928821+0.0127466im    -0.171637+0.081529im     -0.0128842-0.0730044im      0.111032+0.0698857im   -0.0508986-0.235911im       0.091892+0.0906928im
    0.286391-0.0188205im     -0.216215+0.0257499im     -0.188338+0.0882841im     0.0501562+0.0425279im   0.0326143+0.104312im     -0.0447912+0.128935im      0.0232466+0.0191315im     0.0727822+0.0614394im    -0.0541513-0.0309673im     -0.0796639-0.08409im       0.0517023-0.0463611im   -0.0845939-0.145373im       0.24457+0.218283im      -0.0249014+0.0979632im    -0.0394916+0.13172im        0.10429-0.123806im      0.0822796+0.137177im     0.0216585-0.0380311im     0.00922281-0.0277052im   -0.0991789+0.344476im      -0.236143-0.04524im        0.246804-0.0629419im      0.0844471+0.169688im      -0.183349+0.0696266im      -0.231952+0.0402715im      -0.137115-0.0477113im     -0.111769-0.00787274im   -0.263153+0.0891997im     -0.128589-0.0858452im     0.0493419-0.0868853im    0.0356718-0.0959829im     0.0293029-0.058597im
 -0.00672693+0.205321im      0.0147644-0.0976233im      0.112896+0.0329463im    -0.0424437-0.0716273im    0.258193+0.0806556im      0.119804+0.167053im     -0.0710453+0.153311im       0.090828-0.242468im      0.0676725-0.142028im       -0.116285+0.0387436im     0.0209525-0.106352im      0.231649-0.0308469im      0.11435+0.138604im        0.116912+0.0966884im    -0.0237035-0.0896975im     0.111005+0.103348im      0.0376248-0.36148im      -0.162819+0.0256983im      -0.263391-0.128463im     0.0934857+0.115236im    0.000912358-0.00294099im   -0.0138328+0.121148im      -0.0730384+0.00663887im   -0.0637515-0.0473963im       0.010809+0.299665im       0.0426273-0.0962258im     0.0488631-0.0584833im   -0.0153399-0.189059im     -0.0708507-0.0816287im      -0.05097-0.00907924im  -0.0786727+0.0331615im     -0.232421+0.105101im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
   -0.08994567758512143 - 0.04246851477192032im
     0.2987213159985484 + 0.0im
 -0.0007951583639344683 + 0.17442351380467416im
   -0.03547620873702777 - 0.27867725367715823im
    0.15035592522324281 + 0.24944264998296892im
    0.07175779134055951 - 0.048886221312784646im
   -0.03302663097605924 - 0.18564692101942223im
   -0.09988218242364925 + 0.00390039824970356im
   0.013199386189499517 + 0.04019927654998898im
    0.07600900771240517 - 0.024568473394135905im
   -0.09434525705767793 - 0.024827425965045773im
    -0.2797528923953472 - 0.01902646513319972im
    0.02527484604910096 - 0.05040531325310789im
   0.008120775728500267 - 0.0036806654830074496im
   0.035341315842660655 - 0.03765391130318714im
    -0.1274908237035356 - 0.14558843114799092im
    -0.1291820104060895 + 0.1090804760949765im
    0.14291368979782954 - 0.08535010258048713im
   -0.17807664160297665 + 0.09647198354262268im
     0.1689868692165015 - 0.1512489557883286im
    0.04877828710741611 + 0.05726847384150608im
     -0.168224793308861 + 0.08137570635027848im
    0.13398851469931053 - 0.01320787794733248im
    0.15215768287218803 + 0.1038802920965735im
    0.07989875657050735 + 0.20701476819968875im
    0.08008246999872266 - 0.002192321466348196im
   -0.04594662695892797 - 0.07669905823946938im
   0.020725780106669263 + 0.05578268292079267im
     0.2431858969255589 + 0.12744391638577351im
    0.12241230688780821 - 0.1504928056467698im
   0.006612095254674159 - 0.27770258414932625im
   -0.11878937662251882 + 0.03237470015734596im

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.