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.00931172-0.172901im      -0.12963+0.175356im      -0.089956+0.0431464im    -0.0157369+0.083584im       -0.11167-0.192564im     -0.0267506+0.250282im   -0.00180918+0.134372im     -0.104583+0.129958im       0.110365-0.00654375im   -0.143326-0.0850907im     -0.111985+0.378079im    -0.0677984+0.0426486im       0.101313-0.118866im       0.0562971-0.0831929im       0.116991-0.09749im        0.246424-0.0425843im    0.0331027+0.0310859im      0.175723+0.0597785im     -0.213419-0.0189245im      -0.016042-0.0721252im    -0.0414377-0.109098im     0.0364891-0.0122367im     -0.208445+0.00140562im    -0.115834-0.104975im      -0.190671+0.0144795im    -0.118713+0.0362938im    -0.0135735-0.147841im      -0.113601-0.210494im      0.0469347-0.0521115im      0.222119+0.0204415im     0.116885+0.114465im      0.0182798-0.201233im
  -0.0034039-0.0308778im    0.0458386-0.135618im      0.0508045+0.0785115im     -0.157373+0.0418208im       -0.1561-0.136256im       0.274446+0.0523572im   -0.0825707-0.217018im     0.0106953+0.0520586im     -0.244473+0.0807307im    -0.338307+0.0205943im      -0.23219+0.00323155im    0.171736-0.107213im      -0.0935976-0.0420915im      -0.073425-0.0497243im     -0.0602543+0.0114148im     -0.178409-0.0246695im       -0.279-0.0137425im     -0.110681+0.0619854im      0.226982+0.0559618im     -0.0288617-0.0955905im     0.0489691-0.0840107im     0.179417+0.048048im     -0.0374649+0.0402919im     0.0553688+0.116866im       0.022791+0.0247335im   -0.0506554-0.100783im      -0.142628+0.0137247im      0.108816-0.0445422im     -0.037763+0.0208234im     0.0301759+0.186959im      0.267666+0.171459im     -0.0409515-0.154195im
 -0.00468458+0.176425im      0.101909-0.127426im      0.0787755-0.0149025im      0.222899-0.0287383im    -0.0414773+0.114132im     -0.0666437+0.10728im       0.144736-0.00899464im  -0.0950971+0.0834086im     -0.142863+0.192704im    -0.0218004+0.0579724im     -0.251723-0.0235697im    -0.040783-0.0694293im     0.00255481+0.0360079im     -0.0251414-0.285892im       0.0182494-0.289931im      0.0875107-0.0802947im    0.0357524-0.0394989im      0.275939-0.00386071im    0.0162136+0.164195im          0.2539+0.137681im     -0.0607395-0.0265293im     0.128689-0.0923463im     0.0383852-0.00841697im     0.279297+0.127534im      -0.282879-0.179922im     -0.123236+0.0195121im     0.0627911-0.0157978im    0.00420828+0.0319138im     0.0276221+0.0172921im     -0.121111-0.0311159im   -0.0309264-0.0847548im     -0.102265+0.14209im
  -0.0902556+0.200845im     -0.172206+0.199568im       0.033167+0.101119im       0.264638-0.103899im      -0.143042-0.149393im        0.11516+0.0630944im   -0.0656415-0.0491115im     0.200127-0.0843831im        -0.136+0.0147873im    0.0904985-0.0996595im    -0.0114871-0.0793091im    0.0900517+0.0120104im     -0.0375937+0.019051im      -0.0502199-0.119306im      -0.0411901+0.0394545im    -0.0394205+0.226226im      0.113121+0.242641im      0.0851997-0.396658im      0.0220585-0.119833im      -0.0194092+0.0225619im      0.048411-0.0193761im     0.143444+0.218072im     -0.0226061+0.179844im    -0.00819931-0.0944197im      0.119093-0.0805756im    -0.031611-0.00213429im     0.253235-0.192801im     -0.0416057-0.132007im     -0.0192962-0.0977315im     -0.103845+0.106313im   -0.00858807-0.0416576im   -0.00330507-0.0963347im
    -0.16681-0.0806005im    0.0555124+0.0944293im    -0.0141444+0.0424674im    -0.0763337-0.126672im       0.442971-0.0941008im   -0.00472189+0.0375708im   -0.0691657+0.112366im     -0.132554+0.0367213im     -0.293047+0.139662im     -0.118927-0.0331502im    0.00785178+0.0137174im     0.182413+0.0747226im      -0.107708-0.0710461im    -0.00975751+0.0144407im       0.111438-0.0317111im     -0.123329-0.153339im     0.0221738+0.107674im     -0.0724916-0.0796757im    -0.0731567-0.115023im      -0.0349503-0.0537163im   -0.00490971-0.00179605im    0.243372-0.18941im       -0.185891-0.0501266im     0.0410868-0.229036im       0.155593-0.120902im    -0.0369965+0.222811im      -0.119315+0.0724367im    -0.0744087-0.0926668im        0.1169+0.0386335im     -0.124778-0.163077im    -0.0168266-0.142912im      0.0349546+0.150692im
   -0.170446-0.0337265im    -0.166358-0.205286im      -0.158974-0.0204613im     0.0145545-0.00985067im    0.0843067-0.211902im      0.0259131-0.112894im    -0.0796485-0.0482897im      0.10061-0.0607221im    -0.0118424-0.0263774im   -0.0223789+0.0129976im      0.171563+0.0529333im    -0.168918+0.162617im       0.0694499+0.219563im       0.0337881-0.401044im       0.0151096+0.0858439im    -0.0141227-0.0919477im    0.0820479+0.00225513im    -0.125406-0.0865365im    -0.0110202+0.0258274im      -0.107368+0.200559im       0.250359-0.277404im      -0.08724-0.105335im      0.0439536-0.0323829im     0.0222256+0.0483922im    -0.0601703+0.00165243im   -0.072856-0.0260045im     -0.235362-0.0695533im     0.0235125-0.100647im     -0.0077222+0.00555192im    0.0511494+0.102553im     -0.100331+0.150479im      -0.225764+0.205005im
  -0.0231057-0.101844im    -0.0585146+0.0954422im      0.219296-0.147016im      -0.200801-0.159774im      0.0754184-0.106383im       0.245099-0.111245im      0.277233+0.00755752im   0.0331748-0.178883im      -0.078247+0.0568459im    0.0484952+0.145586im     -0.0277622-0.050371im     -0.108888-0.150847im        0.273846+0.0737013im      0.0915619-0.038598im     -0.00726663-0.0596474im    -0.0335284-0.0479494im    -0.132324+0.0194216im      0.104832+0.00640185im     -0.13625-0.120095im       -0.001018-0.276733im      0.0915199-0.204582im    -0.0242934+0.216562im     -0.0162501-0.0137744im     0.0526329+0.0759551im    -0.0772477-0.0153268im     0.019927-0.141221im      0.0344527+0.00792921im    -0.203516-0.0624644im     -0.267896+0.0416215im    -0.0344821-0.252431im    -0.0461526-0.0289451im     0.0801731+0.0852565im
 -0.00685959-0.028145im   -0.00660913+0.112209im     -0.0214896-0.0709397im     -0.107181-0.00502406im     0.174923-0.108034im      0.0639968+0.0808318im     -0.11961+0.0423472im     0.309854+0.0684188im     0.0628781+0.157934im     -0.247442-0.17019im       0.0696754-0.0329629im    -0.164728+0.142804im       0.0374227+0.130355im     -0.00276646+0.151296im       0.0714181-0.384024im     -0.0677117+0.0117084im     0.165554+0.09693im      0.00600642+0.0556406im     0.0867187+0.159378im        -0.14173-0.0651225im     -0.236064+0.119744im    -0.0425308+0.234663im       0.272983-0.101533im      0.0108888+0.0976123im     0.0218024-0.094546im     -0.175105+0.013379im      0.0381898+0.0283781im     0.0756335-0.0173407im     -0.060295+0.138444im       0.106775+0.11355im     -0.0113508-0.0735978im   -0.00900876+0.0939135im
   -0.120829+0.121437im     0.0333175-0.0818627im      0.193143-0.0616019im   -0.00456052-0.0869667im      0.208747-0.0614693im     0.0408232+0.0733214im   -0.0284849+0.0672984im     0.176705-0.044149im       0.317493-0.0698199im     0.106901-0.310705im      -0.113251-0.0872053im    0.0940046+0.0812159im      0.0581127-0.293062im       -0.149941-0.00513583im     -0.044288+0.0507667im     -0.121568-0.0563943im    -0.109423+0.048494im       0.071585+0.174608im      0.0343656-0.0599797im       -0.12727+0.164653im       0.160942-0.0746483im     0.132699-0.189438im       0.184305+0.223112im       0.115863+0.0012639im      -0.12749-0.0324434im   -0.0945422-0.0797573im   -0.00793888+0.0687872im    -0.0900117+0.0426491im    -0.0504066-0.0984523im      0.211257-0.120641im    -0.0127397-0.0729031im    -0.0110315-0.18157im
    0.129967+0.0351197im      0.16437-0.00782652im   -0.0824968+0.231077im      -0.193999-0.0723839im    -0.0040522-0.064304im     -0.0122603+0.081265im      0.121875+0.060842im    -0.0801058-0.110367im      -0.253157+0.00843148im    0.216044+0.0907382im    -0.0437036-0.104657im     -0.320205+0.196153im       -0.170064+0.0375783im     -0.0799036+0.159616im      -0.0831633-0.136882im     -0.0770329+0.16917im      -0.134038+0.137081im      0.0329774-0.0145806im    -0.0737224+0.0454676im     -0.0763117+0.13645im      -0.0532775+0.0316906im     0.120386-0.15753im      -0.0774349+0.133835im      -0.112078+0.0382934im    -0.0915448+0.239637im    -0.0839917-0.122505im      0.0527029-0.0170005im      0.180222-0.193083im     -0.0699441-0.0974874im      0.220592-0.0737895im    -0.111548+0.0599519im    -0.0251399+0.106609im
   0.0922341+0.0586662im    -0.130253-0.0433662im      0.277367+0.0300881im     -0.100709-0.0676433im     0.0849807+0.00501467im    0.0648588-0.0784413im    0.0172185-0.187437im     -0.206964-0.0950141im     -0.237246-0.0312189im    0.0555287-0.0366423im      0.367303-0.0713584im     0.145002+0.022158im       0.0120902+0.00229695im      0.135509-0.0728997im      0.0106689-0.0429274im     0.0844033+0.023153im    -0.0083568+0.0598411im      0.077483-0.0128687im    -0.0471133+0.0233646im      -0.223149+0.0465139im     -0.218229+0.110802im     -0.162277-0.0256652im      0.129868-0.058915im       0.217812-0.142968im      -0.304689-0.112898im      0.155119+0.070742im     -0.0163129-7.86446e-7im    0.0494665-0.0733512im      0.160805-0.07795im        0.169711+0.0977449im    0.0711672+0.0846952im    0.00715108-0.223883im
   0.0575798-0.0447553im    0.0497877+0.0658801im     -0.229842+0.0713476im     -0.113712+0.0610729im     0.0272301+0.030016im     -0.0154847-0.131834im     -0.049222-0.164634im     0.0686451-0.266394im       0.109262+0.0726174im     0.188842-0.0609238im     -0.121145+0.269313im      0.283283+0.0252635im      -0.269083-0.134306im         0.17485-0.126161im        0.156653-0.24948im       -0.015942-0.0120256im    0.0385041-0.0497681im     -0.128728+0.0911456im      0.126259-0.0206207im      0.0414774-0.00943398im  -0.00412836-0.0078219im    -0.105361+0.252976im   -0.000417912+0.22861im       0.0791375-0.0698457im     -0.135417+0.0127264im     0.165901-0.106646im     -0.0427792-0.0314663im     0.0427359-0.113923im     -0.0025742-0.115892im    -0.00687994-0.126155im    0.00374224-0.100242im     -0.0333301+0.197076im
  -0.0218465-0.0735197im    0.0440016+0.0720969im     0.0890791+0.211565im    -0.00537424+0.0629654im     0.0200017-0.071533im     0.00909657+0.163608im     -0.122276+0.0377672im    -0.107114-0.0281408im     0.0737682-0.152066im      0.121321+0.134727im       -0.11649+0.0494955im   -0.0536481-0.191494im        0.448068+0.0410086im       0.129752+0.129293im        0.247099-0.182258im      -0.164565-0.0237196im   -0.0154426+0.118618im     -0.0684611-0.18701im         0.27519+0.0497099im   -0.000715707+0.148708im     -0.0124741-0.0296345im    0.0247373-0.126479im       0.239605+0.0134349im    -0.0163956-0.108302im    -0.00199724+0.115847im      0.144881-0.0425466im    -0.0809127-0.155393im      0.0308554+0.048287im       0.157993+0.059237im      -0.153216-0.120571im     0.0587804+0.0759348im     -0.082325-0.0127079im
   -0.145064-0.014218im      -0.17842+0.360711im       0.171043-0.0406213im    -0.0987107+0.150975im     -0.0338575+0.0571565im      -0.10714+0.118422im      0.246297+0.0786868im    0.0751199+0.116554im     -0.0106495+0.0162071im     0.182512-0.0860357im    -0.0719821+0.0732748im    0.0351714+0.0808162im      -0.218289+0.170135im        0.104507+0.00469235im    -0.0167372+0.213804im      -0.148695+0.0696963im     0.163736-0.000153814im   0.0503189+0.0750736im      0.171564+0.0265944im     -0.0517809-0.130268im     0.00917911-0.110947im      0.296781-0.0467895im      0.103519-0.214141im      0.0316949+0.0931267im     -0.201316+0.106264im      0.202097+0.0482212im     -0.120524+0.0498496im     0.0744892+0.0970506im    -0.0235071-0.0874916im      -0.01424+0.0845705im    0.0369674+0.0694371im    -0.0691062+0.101417im
  -0.0992629+0.247441im    -0.0559827+0.0895389im     -0.129893+0.106645im       0.128647-0.019052im     -0.0852905-0.024357im       0.150745-0.015582im    0.00406296+0.0793202im    -0.074437-0.277976im    0.000160117+0.176552im    -0.0418792-0.203185im      0.0116655-0.0999065im    -0.404946+0.00860525im    -0.0774692+0.0377006im       0.222102-0.0481649im       0.067679+0.0959938im    -0.0890558-0.113363im     0.0126162-0.0422657im     -0.050868+0.1773im        0.0218069+0.165093im        0.213199-0.19921im         0.11463+0.12482im     -0.0409024-0.0479217im     0.0437607+0.0462464im       0.12275-0.203851im      0.0401529+0.15626im      0.0631629+0.0364796im    -0.0718536+0.123504im     -0.0695879-0.0755604im      0.116587+0.149252im     -0.0205317-0.0381257im    0.0999475-0.0552861im     0.0176207-0.234528im
    0.194779+0.19677im     -0.0348123+0.0758771im      0.251347-0.0249011im     -0.100104+0.224298im      -0.110244-0.0432869im     0.0663869+0.104783im    -0.0591302-0.163452im      0.175353-0.105732im      0.0189047-0.215213im       0.15128+0.0746298im     -0.138454+0.0330902im    -0.143716-0.086839im       -0.109301+0.044154im       -0.171182-0.0581989im      0.0446779-0.0186797im      0.188289-0.301099im    -0.0242453+0.0645457im    -0.0187974+0.0490399im    -0.0475666+0.200399im       -0.180364-0.0205094im      0.117157+0.121413im     0.0149149-0.0265712im    -0.0249066-0.143954im     -0.0399862-0.188264im       0.194787-0.231784im    -0.0955206+0.0496947im    -0.0955648+0.106561im      0.0148678-0.137731im      0.0569243-0.165729im     -0.0908476-0.0738243im    -0.016123+0.0298766im      0.101154+0.150531im
    0.116625+0.0402022im    0.0333373-0.039108im     -0.0992053+0.181952im      0.0362692+0.292735im      0.0646975-0.11351im        0.134956-0.255586im    0.00743689+0.0388065im    0.0246827+0.128227im      -0.160774-0.0930612im     0.152046-0.175018im      0.0208988-0.0766414im     0.151783-0.0949534im       0.191213-0.0851729im      -0.114558+0.161309im       -0.135118-0.103775im      0.0932866+0.0121716im     0.165921-0.0410864im      0.198477+0.0602256im    -0.0616359+0.190264im       0.0720317-0.221675im       0.176133-0.173325im     0.0496843-0.0766788im    -0.0365804+0.00541634im    0.0384091-0.133298im      0.0626789-0.022832im      0.190703+0.0111345im    -0.0345151-0.0869414im     0.0968181+0.00328115im   -0.0871689+0.178352im       0.192862+0.152305im    -0.0349089-0.175027im      -0.174555+0.0878335im
   0.0700024+0.0784978im     0.159239-0.0643175im   -0.00283217+0.0953332im     -0.063832-0.257151im     -0.0748282-0.122992im      0.0693823-0.329275im      -0.23731+0.0752383im     0.182888+0.114743im     -0.0942776+0.0966335im     0.177689-0.0229249im   -0.00217026+0.120602im     0.0547229-0.0146682im      0.0059541+0.000281909im    0.0268235-0.0943455im        0.26985+0.0788676im     0.0362261-0.0504039im    0.0906757+0.0234792im      0.363493-0.000922525im  0.00778614-0.0369801im      0.0608954-0.00195283im     0.063806+0.103417im     0.0841487+0.0580082im     0.0512539-0.162041im      -0.138657+0.175233im     -0.0152781+0.15537im     -0.0533248+0.0981663im     -0.184547+0.032528im       0.127743+0.135633im      0.0634906-0.060131im     0.00717625-0.111928im    -0.0347592+0.121839im       0.263371-0.120675im
  -0.0205116+0.145609im    -0.0772279+0.163373im      -0.018964+0.0983768im     -0.216946-0.0989im      0.000586053-0.110542im     -0.0858921-0.18095im     -0.0925018-0.0348317im    0.0854394+0.160161im     -0.0515921-0.154581im     0.0368736-0.162458im      0.0429754+0.0964347im   -0.0950314+0.0332065im     -0.0242295+0.21282im        -0.011296+0.182174im       -0.118645-0.0514912im     0.0954931+0.0515525im    -0.129503-0.0448023im    -0.0113044+0.0294879im      0.244788-0.047695im        0.112557+0.0846065im    -0.0393244+0.0945192im   -0.0720828-0.0603766im      -0.35177-0.0163292im      0.187651+0.066389im     -0.0684178-0.169847im    -0.0928597-0.260016im      -0.089335-0.10996im       -0.318263+0.151143im       0.120754+0.0110284im    -0.0987135-0.0840593im   -0.0315323-0.0517864im     -0.143296-0.0777688im
  -0.0488045-0.170975im      0.252996+0.0549471im    -0.0537525+0.0797987im     -0.114574+0.199505im       0.159018+0.0289185im      0.242477-0.0337595im    -0.018248+0.171732im    -0.0727372-0.0785447im      0.244213+0.0512795im     0.034449-0.0348496im     0.0815989-0.193726im    -0.0642961-0.0734486im      -0.106355-0.00912146im     0.0003939-0.0809899im      0.0294881+0.213438im       0.113734+0.148685im     -0.154429+0.0790959im     0.0504681-0.248194im       0.168918+0.207168im         0.19039-0.0269644im     -0.165998-0.237258im    -0.0836628+0.0598627im    -0.0447258-0.12178im       0.0153869-0.0231073im    -0.0809597-0.181875im     -0.174676+0.0253734im    -0.0696789-0.0353957im      0.052736-0.00207666im    0.0675431-0.265899im     0.00778536+0.0573579im   0.00589206-0.102748im      0.0985791-0.0265339im
   0.0421237-0.0395207im    0.0560119-0.128407im      -0.158516-0.0137062im     0.0230421+0.208924im     -0.0724313-0.106528im      -0.104032+0.0998154im     0.199326-0.101745im     0.0256274+0.0874562im       -0.1324+0.123394im     0.0262827+0.0856226im      0.218531-0.00178461im   -0.122351+0.0727675im     -0.0962443-0.147487im       -0.187117+0.110901im        0.331575+0.0177673im     -0.036942+0.175821im    -0.0734136-0.207808im      0.0395433-0.103026im       0.131085-0.173705im       0.0215274-0.0716438im      0.255441+0.1368im       0.0554466+0.032461im       0.272778-0.0848074im      0.102315-0.129664im     -0.0238159-0.171134im    -0.0469568-0.0184742im    -0.0709286-0.1244im        -0.295482+0.0385112im    -0.0601283-0.0422689im      0.101555-0.0572828im    0.0524526+0.027543im      0.0829012+0.0187968im
    0.159475-0.111953im     0.0472303-0.0704032im    -0.0307548-0.00796445im     0.214651+0.0207838im      0.019284-0.0467537im     0.0826722-0.209157im      0.314325+0.113175im      0.144217+0.0468331im     0.0354916+0.0704642im   -0.0798261+0.0402812im     0.0938237+0.0538845im     0.092864+0.0557944im   -0.000471065+0.0886707im     -0.0759248+0.167233im       0.0601189-0.00197842im   -0.0410434-0.204869im     0.0703385+0.207789im      -0.169493+0.146912im      -0.178163+0.0586763im      0.0570383+0.115963im     -0.0314934-0.0961179im     0.174483+0.0698868im     0.0317779-0.0966225im      0.209461-0.108297im      0.0507202+0.13576im       -0.03291-0.332381im        0.11152-0.0916065im   0.000776319+0.00390029im     0.304506-0.22901im       -0.100568+0.0260986im    0.0343477+0.119415im      0.0463656-0.0653509im
  0.00610223-0.0663836im    -0.156967+0.0374371im     -0.162008+0.0428042im     0.0084422+0.066335im     -0.0527561-0.015963im      0.0754855+0.0275308im    0.0758904+0.0862657im    0.0868618-0.0526494im     -0.146306+0.0679013im     0.136994-0.00757388im    0.0157193+0.0410606im     0.206867+0.0675761im         0.1694+0.0439877im      -0.178735-0.082878im      -0.0107594+0.132399im      0.0155036-0.00887656im  -0.0566721-0.182708im      -0.125068+0.0498618im     0.0147661+0.00680688im    -0.0685161-0.148371im     -0.0954729+0.16184im     -0.0472595-0.149301im       0.156781-0.0732403im      -0.22124+0.0464456im     -0.217205-0.0708148im    -0.280741-0.164256im       0.017488+0.0385956im      0.226577-0.169044im      0.0456328+0.0610147im     -0.276032-0.177476im    -0.0938788-0.258105im      -0.140957-0.226585im
   0.0677191-0.152091im      0.138983-0.0368242im    -0.0512526+0.193169im       0.051008-0.100398im      -0.202908-0.229623im      0.0214649+0.109192im     -0.152784+0.0872119im    -0.102422+0.0853722im    -0.0346817-0.00152862im    0.129393-0.100265im      -0.163461+0.0257532im   -0.0742919-0.0104058im     -0.0144773+0.0704332im      0.0396323-0.0168719im     -0.0663919+0.147254im      -0.182729-0.108874im     0.0592361-0.178347im     -0.0938994-0.00401184im    -0.183425-0.0490568im      -0.296023-0.0270397im    -0.0833721-0.0141337im    -0.170714+0.0509959im     0.0374685-0.154958im       0.403754+0.0441158im     0.0494961+0.0164183im   -0.0180262+0.107082im        0.12492-0.0865643im   -0.00106326+0.154781im      -0.133667-0.201155im     0.00957212-0.0533466im     0.111484-0.257542im     -0.0364565+0.062046im
    0.241149+0.33692im     -0.0694244-0.145518im      -0.259076-0.0419224im      -0.12695+0.0974003im    -0.0817151+0.166217im      0.0554756+0.0938474im    0.0925843+0.0235752im    0.0327353+0.202938im   -0.000464731+0.0327822im     0.108726-0.12872im       0.0744398-0.0184326im     0.106201-0.161648im        0.110252+0.0345181im        0.31481-0.101434im      -0.0306754-0.0191299im     -0.244018-0.151255im     -0.112977+0.0568815im     -0.127391-0.0460837im     0.0397396-0.095203im      0.00104265+0.00932172im    -0.191663-0.118027im      0.146673+0.0336076im    -0.0055718-0.124083im     -0.0988636+0.00700268im     0.095244-0.0296629im    -0.117608+0.144274im       0.041146-0.0128377im     -0.173574-0.0597224im   -0.00467812-0.0673303im      0.220901-0.0741797im    -0.214968+0.016689im     -0.0201994-0.0388989im
   -0.240655+0.0770943im    0.0987915-0.144986im     -0.0565069+0.0954518im    -0.0784129+0.0664712im    -0.0858213+0.0777488im    -0.0490296+0.180928im    -0.0485988-0.195364im    -0.0937249-0.212354im      0.0441283+0.15615im     -0.0880044-0.0856559im    -0.0114485+0.0927666im   -0.0114886+0.051354im        0.107261-0.0121317im      -0.198124+0.105793im      -0.0662655+0.146223im      -0.154536-0.180913im      0.127441+0.306069im       0.155766-0.0422979im     -0.140614-0.133278im        0.125499-0.0917738im    -0.0713717+0.121531im    -0.0730375+0.0812758im    -0.0502885-0.208402im      -0.093232+0.117624im     -0.0112165-0.193765im      0.246792-0.22556im       -0.124711-0.0813059im     0.0527252+0.0527862im     0.0347214-0.0941213im      0.115932-0.0724289im    -0.137886-0.0186874im     -0.137187+0.00685208im
  -0.0770744-0.110369im     -0.073001-0.0095945im      0.232766+0.227459im      -0.186622+0.161893im      0.0703007-0.00667922im     0.124139-0.102091im     -0.128479-0.235803im      0.105308-0.015102im    -0.00407825-0.0258062im   -0.0271792+0.0420863im     -0.037142+0.0401042im    -0.123449+0.10314im       -0.0443766-0.0498556im      0.0827818+0.000928893im     0.139822+0.0701463im    -0.0460496-0.200082im     0.0506575-0.331622im     -0.0246359-0.11428im       -0.148655-0.140293im        0.281174+0.129778im      -0.097518-0.031297im      0.157012-0.045456im      0.0525226-0.0249851im     -0.111456-0.00323801im   -0.0516585+0.0605913im   -0.0237153-0.0338967im      0.423189+0.103548im     -0.0800617+0.0454547im     0.0730518+0.0352613im     0.0700443+0.161552im     -0.112575-0.0912522im    -0.0585529-0.001277im
  -0.0595071-0.038636im     0.0314274+0.309889im     0.00935767+0.0669206im     -0.069967+0.00331878im    -0.157352+0.0553889im     0.0431493-0.115573im     0.0818089-0.110131im     -0.151792+0.235078im       0.127688+0.0111929im   -0.0621006+0.0222397im      0.135867-0.127417im    -0.0522926-0.0643631im      -0.122016-0.0444548im     -0.0620598-0.0465203im    -0.00410509-0.0965247im     -0.114728-0.234028im      0.155243+0.0730925im    -0.0624261+0.0568512im       0.14258-0.235562im       0.0612552+0.0350105im      0.193755-0.0833398im    -0.150081-0.106509im     -0.0150941+0.0417669im      0.130317+0.00141585im   0.00817181-0.156567im     -0.137294+0.0274674im      0.123989-0.190245im       0.390273-0.087529im     -0.0650085+0.152587im      0.0797315-0.168664im     -0.111456+0.0878445im      0.160448-0.0848874im
   -0.155168-0.103382im     0.0505024-0.119804im      0.0609179-0.0369809im     -0.073496-0.0450807im    -0.0522201+0.0830895im     0.0314311-0.0160706im     0.207538-0.0541524im   -0.0427051-0.046795im     -0.0630154-0.125837im     0.0825295-0.217666im      -0.100203+0.0718487im    0.0265091-0.20553im        0.0117044+0.185035im       -0.132094-0.0647414im      0.0169364-0.0586694im     -0.144175+0.174169im      0.134179+0.0370028im     -0.139178-0.0857379im    -0.0598287+0.0722226im     -0.0248955-0.0464444im      0.206849+0.0790771im   -0.0901018+0.12512im      -0.0915411+0.0168855im     -0.143886-0.0182548im    -0.0961738+0.0121726im    -0.243488+0.124243im       0.122001+0.0878606im   -0.00783859+0.178844im       0.434151+0.118451im       0.275009-0.0969134im     0.172871-0.041241im      0.0422179+0.109798im
   0.0392924+0.149557im      0.275475+0.0153191im       0.12251+0.177605im      0.0311847-0.0641142im      0.144737-0.0630186im     -0.286346+0.0862272im   -0.0576173-0.061564im      0.136214+0.0210287im     -0.083232+0.0620878im   0.00335091+0.144521im       0.151913+0.227523im      0.034245-0.0192334im      0.0278252-0.132975im       0.0278339-0.0930314im     -0.0623039+0.139024im      0.0468956+0.0670459im    0.0384206+0.200755im       -0.26384+0.0731938im      0.110683+0.248556im       0.0684877-0.0347592im      0.154351-0.148406im    -0.0610081+0.0915171im    -0.0498056-0.261873im     -0.0212242-0.0550474im     -0.119458+0.0283269im   -0.0421561-0.00346548im     0.281157+0.0870354im    -0.0348942+0.00595643im    -0.213864+0.145841im      0.0465712-0.113353im      0.057405+0.00940624im   -0.0539852-0.1407im
   0.0150676+0.229119im    0.00611759-0.0583756im   -0.00689018+0.0764809im     0.0090698-0.0305477im     0.0864263-0.0781629im   -0.00828606-0.165639im      0.139679+0.0491074im   -0.0469992+0.0256241im       0.17811+0.0849338im    0.0125613-0.16789im        0.101915+0.0676685im   -0.0653445+0.0069343im       0.034602+0.00608517im     0.0673059+0.0934562im     -0.0604696+0.0998559im   0.000439484-0.132738im     -0.219982-0.0572165im     0.0569508-0.0491268im    -0.0566988-0.0942245im     -0.0272631+0.106947im     -0.0395456+0.112063im     0.0716638+0.0386738im     0.0140555-0.0334076im     -0.234783-0.0288087im     -0.108375-0.150607im     0.0263446+0.0655246im      0.127438-0.179916im       0.176077-0.0491161im     -0.107487+0.0609428im     -0.135649-0.0306905im     0.571095+0.07331im      -0.0787156+0.292147im
   -0.216002+0.0619874im   -0.0479961-0.133331im      -0.140262+0.115785im      -0.218121+0.0413191im     -0.053384+0.34303im      0.00594034-0.0406216im   -0.0827876+0.202776im      0.154194-0.0352122im     -0.149107-0.0750405im    -0.150215-0.00382209im   -0.0988821-0.170277im     0.0425312-0.00318602im    -0.0231416-0.0788636im      0.0291762-0.079066im       0.0318392-0.0395266im     0.0886466-0.084588im      0.140312+0.0974078im     0.0546799+0.0432588im     0.0865464+0.0080032im       -0.22322-0.118687im      0.0488241-0.0154366im    -0.145395-0.230647im      0.0224795-0.0854082im    -0.0352119-0.0812706im     -0.144005+0.122899im     0.0202606-0.145605im       0.241863-0.226142im       -0.20995+0.0103776im    -0.0570355-0.0833493im     -0.110909+0.0705214im     0.126765+0.0450099im       0.24676+0.116344im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
  -0.16084502748513863 - 0.31100602975179276im
 -0.004169157556225378 + 0.16492624442725184im
   0.11612926141060284 + 0.08759753825976849im
  0.009880660822177645 + 0.07016067782015721im
  -0.06819551678947115 + 0.12299616679105888im
    0.1693016383548659 + 0.0015336598179491179im
   0.11231672812670587 - 0.12543919387478839im
  -0.03988214804428822 + 0.06000058196658066im
   -0.1491528300057839 - 0.04406573188198382im
   0.01790813937913754 + 0.0023892106219199957im
   -0.0678715579868146 - 0.1026561547452155im
    0.0399720854668571 + 0.06101313743953139im
  -0.22103153068704087 + 0.024237499424919137im
  0.020568792580180857 + 0.0042130461572345585im
  -0.03259686285746925 + 0.12081857398161518im
   0.06447438581863109 + 0.2557737427245682im
  0.007114089098839749 + 0.04603262637257746im
  -0.09550174594452182 + 0.01665493879611714im
   0.22339241630542167 - 0.11534123328844986im
  -0.08480897194474601 - 0.17530082615270942im
    0.0604306677852965 - 0.14302684441024355im
   0.06664510438330393 - 0.02721121185839691im
   0.08877411781995084 + 0.0983923685941239im
  -0.16248491655008887 + 0.02207077595718783im
   0.35806810250127585 + 0.0im
   0.13047399218167605 + 0.010240949374409648im
   0.04192153489747244 - 0.038492636949420934im
    0.3127760043606824 + 0.0034431722902583395im
  -0.07900547434583687 - 0.039268265675075936im
  -0.12591438274204042 + 0.01580983017655154im
   0.09396302922113688 + 0.25648504775381054im
   -0.1661067936946453 - 0.0544824148775804im

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.